Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Silverstripe trailing slashes breaks login

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

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

Page: 1
Go to End
Author Topic: 645 Views
  • Midnightraven
    Avatar
    Community Member
    2 Posts

    Silverstripe trailing slashes breaks login Link to this post

    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.

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: Silverstripe trailing slashes breaks login Link to this post

    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.

  • Midnightraven
    Avatar
    Community Member
    2 Posts

    Re: Silverstripe trailing slashes breaks login Link to this post

    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.

    645 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.