Jump to:

23376 Posts in 18214 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » HTACCESS issue and 400 error

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: 1159 Views
  • Joefunkx
    Avatar
    Community Member
    4 Posts

    HTACCESS issue and 400 error Link to this post

    Hey guys,
    I'm having an .HTACCESS issue that I hope someone can help with. I have done a lot of Google searching but haven't found a solution that worked.

    It is a similar issue to this: http://silverstripe.org/archive/show/35627

    Anyway, my SS site is in a subfolder on my main hosting path, called sssite in this example.

    If I access the site with a slash after the name it works fine: http://www.website.com/sssite/, if I omit the slash then I get the 400 Bad Request error.

    Here is my .HTACCESS file:

    ### SILVERSTRIPE START ###
    <Files *.ss>
       Order deny,allow
       Deny from all
       Allow from 127.0.0.1
    </Files>

    <Files web.config>
       Order deny,allow
       Deny from all
    </Files>

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteCond %{REQUEST_URI} ^(.*)$
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

    If I change the line 5 up from the bottom to: RewriteCond %{REQUEST_URI} ^(.*)/$, then the site will come up fine with no slash, but then when I try to access pages within the site, i.e. http://www.website.com/sssite/page1, I get a "PAGE NOT FOUND" error.

    I also played around with modifying the other .HTACCESS file in my root hosting to specifically add a slash when the sssite name is requested, but that didn't work either.

    Does anyone have any ideas?

  • Joefunkx
    Avatar
    Community Member
    4 Posts

    Re: HTACCESS issue and 400 error Link to this post

    I solved the issue, and in case anyone else runs into it, here is my updated .HTACCESS file with added code in red:

    Note: "sssite" would be replaced with the name of the folder that your site resides in.

    ### SILVERSTRIPE START ###
    <Files *.ss>
       Order deny,allow
       Deny from all
       Allow from 127.0.0.1
    </Files>

    <Files web.config>
       Order deny,allow
       Deny from all
    </Files>

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /sssite
       RewriteCond %{REQUEST_URI} sssite$
       RewriteRule (.*) $1/ [L]

       
       RewriteCond %{REQUEST_URI} ^(.*)$
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

    1159 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.