【问题标题】:htaccess block GET request to specific URLhtaccess 阻止对特定 URL 的 GET 请求
【发布时间】:2015-10-30 04:39:56
【问题描述】:

请求:

    "GET /api/get_recent_posts/?dev=1&page=1 HTTP/1.1" 200 40831 "-" "Mozilla/5.0 (Linux; U; Android 0.5; en-us) AppleWebKit/522+ (KHTML, like Gecko) Safari/419.3"

尝试使用以下命令阻止请求但不起作用

    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} GET
    RewriteRule ^api/get_recent_posts/(.*)$ - [F,NC]

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/api/get_recent_posts/(.*)$
    RewriteRule ^(.*)$ - [F,L]

【问题讨论】:

标签: apache .htaccess mod-rewrite


【解决方案1】:

试试这个

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /api/get_recent_posts/\?dev=([^\s&]+)&page=([^\s&]+)
RewriteRule ^ - [F]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-02
    相关资源
    最近更新 更多