0
我想重定向到错误页面,如果页面未找到。所以我在.htaccess文件中添加了这段代码。找不到htaccess 404问题?
# '404 Not Found' error
ErrorDocument 404 /index.php?p=error&code=404
但是当我测试它不会重定向到index.php文件。
我的整个.htaccess文件代码是在这里
#AuthName "Restricted Area"
#AuthType Basic
#AuthGroupFile /dev/null
#require valid-user
#<Files "/site/captcha/">
# Allow from all
#</Files>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
## File paths are relative to the Document Root (/)
# '400 Bad Request' error
ErrorDocument 400 /index.php?p=error&code=400
# '404 Not Found' error
ErrorDocument 404 /index.php?p=error&code=404
# '403 Forbidden' error
ErrorDocument 403 /index.php?p=error&code=403
# '401 Unauthorized' error
ErrorDocument 401 /index.php?p=error&code=401
# '500 Internal Server Error'
ErrorDocument 500 /index.php?p=error&code=500
############################# Pages ##########################################################
RewriteRule ^home/$ index.php [S=1]
RewriteRule ^home$ index.php [S=1]
</IfModule>
我已经试过这个,但它不会工作。 –
那么你看到了什么错误?是共享主机吗?或者您完全控制了服务器?出于安全/性能的目的,可能完全不处理.htaccess文件/忽略。如果它是你的服务器,那么你可能需要在服务器配置中的适当位置添加'AllowOverride All'指令。否则(如果它是共享托管服务器)联系您的托管公司。 – LazyOne