反正阻止访问特定的网址,对于例如通过htaccess的? [英] Anyway to block visits to specific URLs, for eg via htaccess?

查看:105
本文介绍了反正阻止访问特定的网址,对于例如通过htaccess的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在我的网站阻止访问特定的网址。但我不能确定如何,是可怕的是了解的htaccess的复杂性。 ^^

I need to block visits to specific URLs within my site. But I am unsure how to, and is terrible at understanding the intricacies of htaccess. ^^

我需要阻止访问正在访问这些类型的网址,对于如。

I need to block visits that are accessing these type of URLs, for eg.

  • http://mydomain.com/katherine-blouse-on-fire
  • http://mydomain.com/antique-for-preservation
  • http://mydomain.com/?type=extended&name=stackoverflow

我目前的htaccess code

My current htaccess code

DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]
</IfModule>

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

deny from xx.xx.xx.xx 
deny from xx.xx.xx.xx 

我应该进入htaccess的阻止这些访问?以什么顺序?在我目前的code或之后?

What should I enter into htaccess to block these visits? And in which order? Before my current code or after?

推荐答案

在你的的RewriteBase / 添加下面的前的RewriteCond%{REQUEST_FILENAME}! \(PNG | ... 它会返回一个 403禁止状态code 到客户端

Add the below after your RewriteBase / before RewriteCond %{REQUEST_FILENAME} !\.(png|.... It will return a 403 Forbidden status code to the client.

RewritCond %{REQUEST_URI} (?:(?:katherine-blouse-on-fire)|(?:antique-for-preservation)) [NC,OR]
RewritCond %{QUERY_STRING} type\=extended&name\=stackoverflow [NC]
RewriteRule ^ - [F]

定义:

这篇关于反正阻止访问特定的网址,对于例如通过htaccess的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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