views:

24

answers:

2

Can anyone advise please? I'd like to have the default page for visitors to my site as being index.php and for all non-existent pages the visitor should see errordoc.php

So I've put this in the .htaccess:

ErrorDocument 404 /errordoc.php

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^mysite\.org\.uk$ [NC]
RewriteRule ^(.*)$ http://mysite.org.uk/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Unfortunately everything is going to index.php, including errors. I've tried asking my friend Google but it's his day off today!

+1  A: 

Your last rule will catch all requests that cannot be mapped onto existing files (RewriteCond %{REQUEST_FILENAME} !-f) or existing directories (RewriteCond %{REQUEST_FILENAME} !-d). That’s why the error document will not be served.

Gumbo
I see - thanks!
Outerbridge Mike
+1  A: 

you have 2 incompatible sections in this file. choose one
leave either only first line or only the rest of the file. But not both.

Bottom three lines tells web-server to direct all non-existent pages to the index.php, not to errordoc.php

Col. Shrapnel
I see - thanks!
Outerbridge Mike