Greetings,
I cant get my htaccess mod_rewrite working as it should.. I have some basic RewriteRules for 开发者_如何学运维some static underpages, a redirect from the non www-version and now I would like to add a custom 404-page (called 404.php located in my webroot.
What happens is that when I try to access the underpage it only throws the 404-message back to me over and over again... Can anyone see any problems with this code?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)$ /404.php [L]
RewriteCond %{HTTP_HOST} ^dhb\.nu$
RewriteRule (.*) http://www.dhb.nu/$1 [R=301,L]
RewriteRule ^policy/$ page.php?page_id=11
RewriteRule ^cookies/$ page.php?page_id=13
Thanks in advance!
Try using this:
ErrorDocument 404 /404.php
Read more here: http://www.garnetchaney.com/htaccess_tips_and_tricks.shtml
Instead of
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)$ /404.php [L]
you should really use the ErrorDocument directive:
ErrorDocument 404 /404.php
精彩评论