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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Silverstripe trailing slashes breaks login


Go to End


3 Posts   1803 Views

Avatar
Midnightraven

Community Member, 2 Posts

2 June 2011 at 6:16am

Hi, I've been asked to updated the .htaccess file on a website to always add trailing slashes onto the URLs, e.g.
"www.xyz.co.uk/news" -> "www.xyz.co.uk/news/"

I added this code to my htaccess file on the apache web server:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.xyz.co.uk/$1/ [L,R=301]

This is working really well, except that with these rules, when I attempt to login to Silverstripe "www.xyz.com/admin", when I input my (correct) user name & password, Silverstripe responds with "That doesn't seem to be the right e-mail address or password. Please try again".

I am having trouble identifying where the login is getting disrupted. I would be grateful for any advice on an additional rule/tweak that would allow the admin login to function correctly.
Regards,
AndyH.

Avatar
(deleted)

Community Member, 473 Posts

2 June 2011 at 8:36am

Your RewriteRule will include POST requests, so submitting the login form to /Security/LoginForm will get redirected to /Security/LoginForm/ and turned into a GET. You should add a condition to your rule so that it excludes POST requests.

Avatar
Midnightraven

Community Member, 2 Posts

3 June 2011 at 4:04am

Ahh, I see. Thank you, I understand the logic of the login process better now.

For other peoples reference, these are the updated htaccess rules:
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.xyz.co.uk/$1/ [L,R=301]

Thanks.