【问题标题】:.htaccess - Allow acess if "REQUEST_URI" is my defined path.htaccess - 允许访问“REQUEST_URI”是我定义的路径
【发布时间】:2015-03-27 18:53:27
【问题描述】:

我目前阻止访问我网站的全部内容,只允许某些 IP 访问。

RewriteCond %{HTTP:CF-Connecting-IP} !^/?198.252.206.140$
RewriteRule ^ - [F,L]

但我想允许所有人访问文件夹 /content/upload/ 的任何文件,并使用 REQUEST_URI。我试过类似的东西。

RewriteCond %{HTTP:REQUEST_URI} !^/?/content/upload/*$
RewriteCond %{HTTP:CF-Connecting-IP} !^/?198.252.206.140$
RewriteRule ^ - [F,L]

但效果不佳。

【问题讨论】:

    标签: .htaccess mod-rewrite rules


    【解决方案1】:

    您可以在 root .htaccess 中使用此规则:

    RewriteCond %{HTTP:CF-Connecting-IP} !^/?198\.252\.206\.140$
    RewriteRule !^content/upload(/.*)?$ - [F,L,NC]
    

    【讨论】:

    • 工作,谢谢。但我只是使用了“RewriteRule!^content/upload(/.*)?$ - [F,L,NC]”,我保持 ip“干净”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-04
    • 2021-04-17
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多