dongwen9975
2015-09-17 02:00
浏览 212
已采纳

403 .htaccess中的403错误

I have a custom 403 page forbidden.php

I have added it to .htaccess but not working

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^notfound\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound.php [L]
ErrorDocument 403 . /forbidden.php
</IfModule>


<Files 403.shtml>
order allow,deny
allow from all
</Files>

I have also tried:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^notfound\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound.php [L]
</IfModule>


<Files forbidden.php>
order allow,deny
allow from all
</Files>

What am I missing. .htaccess is not my strong point

图片转代码服务由CSDN问答提供 功能建议

我有一个自定义403页面forbidden.php

我添加了它 到.htaccess但没有工作

 &lt; IfModule mod_rewrite.c&gt; 
RewriteEngine On 
RewriteBase / 
RewriteRule ^ notfound \ .php $  -  [L] 
RewriteCond%{REQUEST_FILENAME  } -f 
RewriteCond%{REQUEST_FILENAME}!-d 
RewriteRule。  /notfound.php [L] 
ErrorDocument 403。  /forbidden.php
</IfModule>


<Files 403.shtml&gt; 
order allow,deny 
allow from all 
&lt; / Files&gt; 
   
 \  n 

我也尝试过:

 &lt; IfModule mod_rewrite.c&gt; 
RewriteEngine On 
RewriteBase / 
RewriteRule ^ notfound \ .php $  -  [L] 
RewriteCond  %{REQUEST_FILENAME}!-f 
RewriteCond%{REQUEST_FILENAME}!-d 
RewriteRule。  /notfound.php [L] 
&lt; / IfModule&gt; 
 
 
&lt; Files forbidden.php&gt; 
order allow,deny 
allow from all 
&lt; / Files&gt; 
    
 
 

我错过了什么。 .htaccess不是我的强项

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxiajia6104 2015-09-17 05:36
    已采纳

    The correct ErrorDocument syntax is:

    ErrorDocument <3-digit-code> <action>
    

    See http://httpd.apache.org/docs/2.4/custom-error.html

    Actually it's not mod_rewrite dependent, you could put the ErrorDocument outside of the condition.

    Also, are you trying to achieve a 404 custom document with rewrite rules???

    Just use that, done.

    ErrorDocument 404 /nofound.php
    ErrorDocument 403 /forbidden.php
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题