I want to redirect all 404 errors to "404.php" for example.
我想将所有404错误重定向到“404.php”。
I've tryed using ErrorDocument 404 /404.php
in .htaccess, but without luck, perhaps my other rules are not allowing this somehow, I'm not really sure as I couldn't find this info on www.
我尝试在.htaccess中使用ErrorDocument 404 /404.php,但没有运气,也许我的其他规则不允许这种方式,我不太确定,因为我无法在www上找到此信息。
If anyone have idea how to solve this, please shout :P
如果有人知道如何解决这个问题,请大声呼喊:P
My current .htaccess
我现在的.htaccess
#### pie thingy ####
AddType text/x-component .htc
#### Rule for Error Page - 404 ####
ErrorDocument 404 /404.html
#### url rewriting ####
Options +FollowSymlinks
RewriteEngine on
#### REDIRECT IF NO SUB-DOMAIN ####
RewriteCond %{HTTP_HOST} ^([^.]+)\.([^.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1.%2/$1 [R=301,L]
#### Remove "www." from any subdomain requests ####
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.precisehire\.com [NC]
RewriteRule (.*) http://%1.precisehire.com/$1 [R=301,L]
#### Rules for rewriting from PHP to HTML with fallback ####
RewriteCond %{REQUEST_URI} ^/(.*)\.html$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)\.html$ $1.php [nc]
2 个解决方案
#1
12
Solved by placing full URL for error document.
通过放置错误文档的完整URL解决。
Example:
例:
#### Rule for Error Page - 404 ####
ErrorDocument 404 http://www.domain.com/404.html
#2
0
It's not necessary to give the full URL. You can also mention the absolute path like
没有必要提供完整的URL。你也可以提一下绝对路径
ErrorCodument 404 /pages/error.php
which is a better way of doing this than the accepted answer.
这是比接受的答案更好的方式。
#1
12
Solved by placing full URL for error document.
通过放置错误文档的完整URL解决。
Example:
例:
#### Rule for Error Page - 404 ####
ErrorDocument 404 http://www.domain.com/404.html
#2
0
It's not necessary to give the full URL. You can also mention the absolute path like
没有必要提供完整的URL。你也可以提一下绝对路径
ErrorCodument 404 /pages/error.php
which is a better way of doing this than the accepted answer.
这是比接受的答案更好的方式。