【问题标题】:.htaccess allow all sorts of content types.htaccess 允许各种内容类型
【发布时间】:2015-03-11 10:27:27
【问题描述】:

我的 public_html 文件夹中有一个 .htaccess,它只允许特定的内容类型,该部分如下所示:

# BAD Content Type ^
# Denies any POST request with a content type other than application/x-www-form-urlencoded|multipart/form-data
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:Content-Type} !^(application/x-www-form-urlencoded|multipart/form-data.*(boundary.*)?)$ [NC]
RewriteRule .* - [F,NS,L]

我有一个子域,它应该允许各种内容类型(由于外部发布方法)。 所以我想知道如何告诉 .htaccess 我的子域不应该被阻止。 我怎样才能做到这一点?

【问题讨论】:

    标签: php apache .htaccess mod-rewrite content-type


    【解决方案1】:

    只需使用%{HTTP_HOST} 变量添加另一个RewriteCond

    RewriteCond %{HTTP_HOST} !^subdomain\. [NC]
    RewriteCond %{REQUEST_METHOD} =POST
    RewriteCond %{HTTP:Content-Type} !^(application/x-www-form-urlencoded|multipart/form-data.*(boundary.*)?)$ [NC]
    RewriteRule .* - [F,NS,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-26
      • 2021-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-28
      • 1970-01-01
      相关资源
      最近更新 更多