没有显示在状态(200 OK)403 code和一些网页 [英] Not showing 403 code in status (200 OK) and some page

查看:287
本文介绍了没有显示在状态(200 OK)403 code和一些网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的作品,错误code 404 code,但对于403 code不工作。它不显示页面403.html和continu显示code 403的状态,而不是200 OK。为什么呢?

 从adsl.eunet.rs拒绝
RewriteEngine叙述上
的RewriteBase /

重写规则^ 403 \ html的/ $  -  [L]

#如果所需的文件犯规存在
#如果所需的文件是不是现有目录
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。 403.html [L]
 

解决方案

请你的.htaccess这样的:

  ###从adsl.eunet.rs拒绝

ErrorDocument的403 /403.php
RewriteEngine叙述上
的RewriteBase /

的RewriteCond%{REMOTE_ADDR} = 194.247.196.20
重写规则^!(404 | 403)\。 - [F]

重写规则^(404 | 403)\。 -  [L]

#如果所需的文件犯规存在
#如果所需的文件是不是现有目录
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。 404.html [L]
 

然后在 /403.php 开始与这个PHP code:

 < PHP
   http_response_ code(200);
   #休息你的HTML code
?>
 

Code below works for error code 404 but for 403 code is not working. It doesn't show page 403.html and continu to show code 403 in status instead of 200 OK. Why?

Deny from adsl.eunet.rs 
RewriteEngine On
RewriteBase /

RewriteRule ^403\.html/?$ - [L]

# If the requested file doesnt exist
# and if the requested file is not an existing directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . 403.html [L]

解决方案

Keep your .htaccess like this:

### Deny from adsl.eunet.rs 

ErrorDocument 403 /403.php
RewriteEngine On
RewriteBase /

RewriteCond %{REMOTE_ADDR} =194.247.196.20
RewriteRule !^(404|403)\. - [F]

RewriteRule ^(404|403)\. - [L]

# If the requested file doesnt exist
# and if the requested file is not an existing directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . 404.html [L]

Then inside /403.php start with this php code:

<?php
   http_response_code ( 200 );
   # rest of your html code
?>

这篇关于没有显示在状态(200 OK)403 code和一些网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆