Jump to:

4873 Posts in 7171 Topics by 1471 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » [SOLVED] Enabling mod_rewrite

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

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

Page: 1 2
Go to End
Author Topic: 2393 Views
  • SnowBoarder82
    Avatar
    Community Member
    52 Posts

    [SOLVED] 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
    52 Posts

    Re: [SOLVED] 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
    19 Posts

    Re: [SOLVED] 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
    19 Posts

    Re: [SOLVED] 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: [SOLVED] 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
    30 Posts

    Re: [SOLVED] 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

  • arthurdent
    Avatar
    Community Member
    132 Posts

    Re: [SOLVED] Enabling mod_rewrite Link to this post

    Playing around with Silverstripe 3...

    Still (after 6 months) can't get mod_rewrite to work. I've tested php setup and mod_rewrite is loaded.

    <?php phpinfo(); ?>

    I've located my .htaccess file (that's a bundle of fun on a Mac!), which reads as follows:

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

    # This denies access to all yml files, since developers might include sensitive
    # information in them. See the docs for work-arounds to serve some yaml files
    <Files *.yml>
       Order allow,deny
       Deny from all
    </Files>

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

    <IfModule mod_alias.c>
       RedirectMatch 403 /silverstripe-cache(/|$)
       RedirectMatch 403 /vendor(/|$)
       RedirectMatch 403 /composer\.(json|lock)
    </IfModule>

    <IfModule mod_rewrite.c>
       SetEnv HTTP_MOD_REWRITE On
       RewriteEngine On
       RewriteBase '/SilverStripe-cms-v3.0.5'

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

    Still no joy...

    Seems to be a pretty common problem. Not sure if it's affecting my local install of SS (which is developing problems of its own which you can see in my other posts)... question is, has anybody solved it?

    Running Mac OSX 10.8 with MAMP, used to have it all working on my old G5 running OSX 10.4 and XAMPP -- life seemed so much simpler then...

    comments anybody?

  • DanielB
    Avatar
    Community Member
    5 Posts

    Re: [SOLVED] Enabling mod_rewrite Link to this post

    I don't know if this is helpful but here goes...

    I've just installed xampp to run my Silverstripe sites from in development.

    If I have index.php in the root directory the rewriting of urls seems to fail and if I remove it the rewriting of the urls works fine. Any ideas as to why this might be?

    2393 Views
Page: 1 2
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.