简体   繁体   English

htaccess mod_rewrite QUERY_STRING

[英]htaccess mod_rewrite QUERY_STRING

I want to block access to certain urls if there's no referrer I tried the following rule set but it isn't working 如果没有引荐来源网址,我想阻止对某些网址的访问,但我尝试了以下规则集,但无法正常工作

RewriteEngine On RewriteEngine开

RewriteCond %{HTTP_REFERER} !^http(s)?://.*$ [NC] RewriteCond%{HTTP_REFERER}!^ http(s)?://.*$ [NC]

RewriteRule script.php\\?do=item&id=[a-f0-9]{8}$ / [L] RewriteRule script.php \\?do = item&id = [a-f0-9] {8} $ / [L]

apparently I have to use %{QUERY_STRING} but I don't know what to do, the apache docs are unclear 显然我必须使用%{QUERY_STRING},但我不知道该怎么做,apache文档尚不清楚

Can you help me rewrite this rule please? 您能帮我重写此规则吗?

If you want to match a query string, you have to compare it to %{QUERY_STRING} in a RewriteCond: 如果要匹配查询字符串,则必须在RewriteCond中将其与%{QUERY_STRING}进行比较:

RewriteEngine On

RewriteCond %{HTTP_REFERER} !^http(s)?://.*$ [NC]
RewriteCond %{QUERY_STRING}  ^do=file&id=[a-f0-9]{8}$ [NC]
RewriteRule script.php / [L]

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

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