【发布时间】:2023-03-25 07:40:01
【问题描述】:
如果找不到该页面,我想重定向到错误页面。所以我在 .htaccess 文件中添加了这段代码。
# '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 http-status-code-404