简体   繁体   English

HTACCESS,如果IP错误,则呈现404而不是403

[英]HTACCESS, render 404 instead of 403 upon wrong ip

Directory viewing would render 403 upon wrong ip: 目录查看将在错误ip时呈现403:

order deny,allow  
deny from all  
allow from 111.222.333.444

Simple and clear, so lets move on... 简单明了,让我们继续前进...
then tried to gobble up some code to render 404 instead of 403: 然后尝试吞噬一些代码以呈现404而不是403:

order deny,allow  
deny from all  
allow from 111.222.333.444
RedirectMatch 404 ".*\/\..*"

And the above does not work, what have I missed? 以上都不起作用,我错过了什么?

SPECS 眼镜
1. .htaccess is inside a subdir 1. .htaccess在子目录中
2. file is executed by virtualhost 2.文件由virtualhost执行

NB NB
And by rendering, I mean recieving headers vs visual trickery. 通过渲染,我的意思是接收标题与视觉欺骗。

Mod_rewrite can solve your problem. Mod_rewrite可以解决您的问题。

Add the following to your htaccess. 将以下内容添加到您的htaccess中。

RewriteEngine on


RewriteCond %{REMOTE_ADDR} !^1.2.3.5$
RewriteRule ^ - [R=404,L]

Replace 1.2.3.5 with your ip address. 用您的IP地址替换1.2.3.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM