Jump to:

4576 Posts in 1387 Topics by 1377 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Enabling mod_rewrite

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1164 Views
  • SnowBoarder82
    Avatar
    Community Member
    28 Posts

    Enabling mod_rewrite Link to this post

    Hi there,

    I'm a semi newb to silverstripe and have had a great experience so far working with the platform. I have successfully loaded silverstripe onto a few different servers for various projects, but have come across an issue after having a client request to use Telecom as their webhost.
    During installation I'm getting the warning that mod_rewrite has not been enabled - I've searched through the forum on similar issues but so far have not found a definitive solution.
    Having been in touch with Telecom on this they assure me that mod_rewrite is enabled on their system and that the problem lies in my .htaccess file (for which they provide no support).

    Here is the .htaccess file as it currently sits (fresh at install):

    ### 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>

    ErrorDocument 404 /assets/error-404.html
    ErrorDocument 500 /assets/error-500.html

    <IfModule mod_alias.c>
       RedirectMatch 403 /silverstripe-cache(/|$)
    </IfModule>

    <IfModule mod_rewrite.c>
       SetEnv HTTP_MOD_REWRITE On
       RewriteEngine On

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

    Here is also the latest message from Telecom's support desk:

    "We support making sure that mod rewrite is working, but we do not support the syntax of a .htaccess file. That falls under the purview of coding.

    Looking at the error log for the site shows that this is not an issue with mod_rewrite, but is an issue with an infinite loop written into the rewrite code. Fixing that should allow for the use of mod rewrite.

    See below in www/logs/error_log:

    [28/Aug/2011:19:41:38 +0000] [error] [client 114.207.113.111] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    [28/Aug/2011:19:41:38 +0000] [error] [client 114.207.113.111] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    [28/Aug/2011:19:41:38 +0000] [error] [client 114.207.113.111] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    [28/Aug/2011:19:41:39 +0000] [error] [client 114.207.113.111] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    [28/Aug/2011:19:41:39 +0000] [error] [client 114.207.113.111] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    [29/Aug/2011:05:47:13 +0000] [error] [client 198.65.168.24] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    [29/Aug/2011:05:47:13 +0000] [error] [client 198.65.168.24] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if necessary.
    "

    A solid solution would be much appreciated - pretty much at a loss here....

    Thanks in advance!

  • SnowBoarder82
    Avatar
    Community Member
    28 Posts

    Re: Enabling mod_rewrite Link to this post

    No love...

    No worries, Telecom wasn't any further help either - Have decided to change to another hosting company where these issues don't exist. I guess the moral of the story is to use a recommended host from the start.

    Cheers,

  • BigMoose
    Avatar
    Community Member
    10 Posts

    Re: Enabling mod_rewrite Link to this post

    I am having the exact same problem - different provider though. Are there any ideas on solving this? Furthermore, is it safe to continue the installation and remedy this afterwards?

  • BigMoose
    Avatar
    Community Member
    10 Posts

    Re: Enabling mod_rewrite Link to this post

    Okay, my solution was to place the entire silverstripe website into a subfolder named 'ss'. My problem persisted beacuse the internet service provider already makes use of 'www.yoursite.com/admin' to log into their own site administration area. This of course is the same address for the cms login. So when I proceeded with the installation, all the URLs appeared correctly, but the admin was found at 'www.yoursite.com/index.php/admin'.

    This seemed to also lead to problems where if a user clicked 'view published site' or 'draft site' from the cms it would take them to a '404 page not found'.

    So by putting everything into a subfolder and creating a redirect index.php file in the website's root, I was able to solve all my issues.

    For future reference - Can the login page 'www.yoursite.com/admin' be changed to another url? This may solve the headache for others.

  • Terrence
    Avatar
    Community Member
    2 Posts

    Re: Enabling mod_rewrite Link to this post

    Issue is with index.php
    There is a line where a string comparison is done without taking into account of the different separators for windows and linux.
    Change the following line
       $fileURL = (dirname($_SERVER['SCRIPT_NAME'])=='/'?'':dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
    to
       $fileURL = (dirname($_SERVER['SCRIPT_NAME'])==DIRECTORY_SEPARATOR?'':dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
    and that should solve your problem.

  • Dazman1
    Avatar
    Community Member
    28 Posts

    Re: Enabling mod_rewrite Link to this post

    Hi

    Not sure if this will help.

    Include the rewrite base after rewrite engine

    like this

    ### 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>

    ErrorDocument 404 /assets/error-404.html
    ErrorDocument 500 /assets/error-500.html

    <IfModule mod_alias.c>
       RedirectMatch 403 /silverstripe-cache(/|$)
    </IfModule>

    <IfModule mod_rewrite.c>
       SetEnv HTTP_MOD_REWRITE On
       RewriteEngine On
       RewriteBase /

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

    if your site is in a sub domain the rewrite would be something like this RewriteBase/Mysite

    If its in the root/Public_html then Leave the rewrite base as it is

    let me know

    Darren

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