Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

BackURL redirect from base page

Go to End

2 Posts   1248 Views


Community Member, 3 Posts

13 May 2014 at 1:01pm

When my users first go to the website, they use the URL and they are redirected to, if they try to login, they are redirected back to that same page.

My login form has the following code that refers to the BackURL:

if (isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} else {
$backURL = Session::get('BackURL');

If I click on the logo, the page refreshes and takes me to and then they can login successfully. Is there any way to fix it so when they enter, they are taken to I feel like I’m missing an if\then statement that would be the catchall for when they go to the root and don’t enter the index.php.

I'm new to PHP and web development in general, but it seems to me there should be a way to say if the BackURL variable is null then backurl=index.php

Tim Snadden

Community Member, 32 Posts

15 May 2014 at 8:42pm

You shouldn't need to create your own login form. If the user doesn't have permission to view a particular part of the site they should get directed to Security/login with a BackUrl set to where they came from. Once they have logged in they should be shown the content. Try putting something like this in your Page class (or some other permission check). Make sure that your template includes $Form.

	public function canView($member = null) {
		return Permission::check('SITETREE_VIEW');