.htaccess RewriteCond

时间:2013-01-31 18:34:56

标签: web-services apache .htaccess

任何人都可以使用这个.htaccess文件来阻止我,我一直试图做一个例外,所以我可以访问我的子域名,这是 form.domain.com 我试过了 RewriteCond%{REQUEST_URI}!^ / form /?$ 和其他几个命令,但没有运气

.htaccess:

#######################
#   N - T H I N G !   #
#######################

# Apache options
Options +FollowSymLinks -Indexes
RewriteEngine on

# Allow only GET and POST verbs
RewriteCond %{REQUEST_METHOD} !^(GET|POST)$ [NC,OR]

# Ban Typical Vulnerability Scanners and others
# Kick out Script Kiddies
RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget).* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*(libwww-perl|curl|wget|python|nikto|wkito|pikto|scan|acunetix).* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*(winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner).* [NC,OR]

# Error Page
ErrorDocument 404 /404

# Redirect attachments
RewriteRule ^files/attachments/(.*)/(.*)/(.*)$ files/attachments/$1/$2/$3 [L]

# Redirect all requests to index.php
RewriteRule ^(.*)$ index.php [L,QSA]

1 个答案:

答案 0 :(得分:0)

要匹配域名,您应该使用%{HTTP_HOST},如下所示:

RewriteCond %{HTTP_HOST} ^form.domain.com$
RewriteRule ^.*$ - [L]

如果域名与form.domain.com匹配,则允许URL并停止处理规则。

有关详细信息,请参阅Apache documentation