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.

Installing SilverStripe /

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

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

[SOLVED] Enabling mod_rewrite


Go to End
Reply


12 Posts   3426 Views

Avatar
SnowBoarder82

Community Member, 55 Posts

31 August 2011 at 8:23am

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!

Avatar
SnowBoarder82

Community Member, 55 Posts

12 September 2011 at 6:15am

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,

Avatar
BigMoose

Community Member, 19 Posts

5 November 2011 at 6:14am

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?

Avatar
BigMoose

Community Member, 19 Posts

8 November 2011 at 4:59am

Edited: 08/11/2011 5:00am

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.

Avatar
Terrence

Community Member, 2 Posts

24 December 2011 at 11:43am

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.

Avatar
Lexandclo

Community Member, 36 Posts

19 January 2012 at 3:58am

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

Avatar
arthurdent

Community Member, 180 Posts

27 June 2013 at 4:19pm

Edited: 27/06/2013 4:21pm

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?

Avatar
DanielB

Community Member, 5 Posts

10 January 2014 at 12:18pm

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?

Go to Top