views:

342

answers:

3

Hi, I'm trying to install SilverStripe and during the installation, it returns an error saying that friendly links aren't working. However mod_rewrite is enabled and AllowOverride is set to All. I'm using CentOS Linux on a dedicated server with Webmin as the cp (yes, I know.. not my choice).

+1  A: 

Step 1. Put some garbage in your .htaccess file and see if the web server gives you an error.

brianegge
A: 

The point here being to find out - assuming the server is running Apache - whether the .htaccess file the SS installer generated is actually being read. If you've still problems, try asking on the SS IRC channel.

Toby Champion
A: 

The installer should have set things up as best it can, even if you receive that error message.

This question is a little tricky to answer because the problem could lie in a number of different places, but I've tried to put together a troubleshooting guide below.

Note: Many of the links below have been deliberately broken because Stack Overflow think I might be a spammer. ;-)

Assuming that your site is at http:/www.example.com, try visiting http:/www.example.com/dev/build - you should see a page with a heading "Environment Builder (formerly db/build)". If that works, then you have no problems with rewrite, and the installer gave you that message in error.

If that gives you a 404, try http:/www.example.com/sapphire/main.php?url=dev/build - this will visit the same feature, but bypasses mod_rewrite. If that gives you the heading "Environment Builder (formerly db/build)" and the previous URL didn't, then you have a problem with mod_rewrite and not some other problem.

  1. Check the content of your .htaccess file. It should look something like this but may have RewriteBase line.
  2. Try putting some junk text - e.g. 'asdfsahjadsfasdf' - into the .htaccess file and saving. Open your site. Does it give you a 500 error? If not, then your AllowOverride All setting isn't working. Check that you have set it in the right place. Remember - it needs to be in your Apache config file, and not the .htaccess. If you don't have access to the relevant config files you might need to ask your ISP to help you answer this question.
  3. If that doesn't uncover the issue, we'll have to tinker with the rewrite rules to see if we can explore what's going on. Try changing this line:

    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    

    To this (it will turn the rewrite rules into redirection rules):

    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L,R]
    

    Visit http:/www.example.com/dev/build again Did it redirect anywhere? If not, then mod_rewrite isn't working. It should be redirecting to http:/www.example.com/sapphire/main.php?url=dev/build. Is it redirecting somewhere else? For example, has extra junk been inserted into the ?url= parameter? This can sometimes happen if you are running SilverStripe in a subdirectory. In this case, check that the RewriteBase setting is set that subdirectory. Something like RewriteBase /mysubdir.

If you're still unable to get friendly URLs working, then congratulations - you've found a really nasty edge-case! Post the details of what you discovered following the steps above to the SilverStripe IRC channel or Forum on www.silverstripe.org.

Sam Minnée