2012-02-13 87 views
0

我需要阻止訪問我的網站中的特定網址。但我不確定如何去理解htaccess的錯綜複雜情況。 ^^無論如何阻止訪問特定的URL,例如通過htaccess?

我需要阻止訪問這些類型的URL的訪問,例如。

我當前的htaccess代碼

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來阻止這些訪問?並以什麼順序?之前我目前的代碼或之後?

回答

1

請在RewriteBase /之後加 以下。它會將403 Forbidden status code返回給客戶端。

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

定義:

0

如果您有可用的話,您可能會也可能不希望使用mod_alias;語法稍微更具可讀性,但它只會匹配路徑(即不包含查詢字符串):

<IfModule mod_alias.c> 
Redirect 403 /katherine-blouse-on-fire 
Redirect 403 /antique-for-preservation 
</IfModule>