.htaccess 未找到htaccess 404中的问题?

.htaccess 未找到htaccess 404中的问题?,.htaccess,http-status-code-404,.htaccess,Http Status Code 404,如果找不到错误页,我想重定向到错误页。所以我在.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 val

如果找不到错误页,我想重定向到错误页。所以我在.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>
#AuthName“禁区”
#AuthType Basic
#AuthGroupFile/dev/null
#需要有效用户
#
#通融
# 
选项+FollowSymLinks
重新启动发动机
##文件路径相对于文档根(/)
#“400错误请求”错误
ErrorDocument 400/index.php?p=error&code=400
#“404未找到”错误
ErrorDocument 404/index.php?p=error&code=404
#“403禁止”错误
ErrorDocument 403/index.php?p=error&code=403
#“401未经授权”错误
errordocument401/index.php?p=error&code=401
#“500内部服务器错误”
ErrorDocument 500/index.php?p=error&code=500
#############################页数##########################################################
重写规则^home/$index.php[S=1]
重写规则^home$index.php[S=1]
首先——将所有
错误文档
指令移出
——根本不需要这样做

现在它告诉Apache:“只有在启用mod_rewrite时才使用ErrorDocument”

如果它现在对您不起作用,那么很可能实际上没有启用mod_rewrite。但是如果您将它们放在
块之外(就在它前面),那么它应该可以工作(只要.htaccess被Apache识别和处理):

#AuthName“禁区”
#AuthType Basic
#AuthGroupFile/dev/null
#需要有效用户
#
#通融
# 
选项+FollowSymLinks
#“400错误请求”错误
ErrorDocument 400/index.php?p=error&code=400
#“404未找到”错误
ErrorDocument 404/index.php?p=error&code=404
#“403禁止”错误
ErrorDocument 403/index.php?p=error&code=403
#“401未经授权”错误
errordocument401/index.php?p=error&code=401
#“500内部服务器错误”
ErrorDocument 500/index.php?p=error&code=500
重新启动发动机
#页数
重写规则^home/?$index.php[L]
p.S.
我还修改了您的重写规则:将它们合并成一个规则。

那么您看到了什么错误?是共享托管还是完全控制服务器?出于安全/性能目的,.htaccess文件可能根本未被处理/忽略。如果是您的服务器,则可能需要在服务器配置的适当位置添加
AllowOverride All
指令。否则(如果是共享托管服务器)请联系您的托管公司。
#AuthName "Restricted Area" 
#AuthType Basic 
#AuthGroupFile /dev/null 
#require valid-user
#<Files "/site/captcha/">
#  Allow from all
#</Files> 

Options +FollowSymLinks

# '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

<IfModule mod_rewrite.c>
  RewriteEngine on 
  # Pages
  RewriteRule ^home/?$ index.php [L]
</IfModule>