【问题标题】:Convert apache htaccess rewrite rules to nginx rewrite rules将 apache htaccess 重写规则转换为 nginx 重写规则
【发布时间】:2014-06-30 19:42:30
【问题描述】:

有人可以帮我把这个规则转换成 nginx 吗?我需要它将 html 用作 FireFox 中 svg 掩码的 xhtml

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml\s*;\s*q=0
RewriteCond %{REQUEST_URI} \.html$
RewriteCond %{THE_REQUEST} HTTP/1\.1
RewriteRule .* - [T=application/xhtml+xml]

【问题讨论】:

    标签: apache .htaccess nginx rule


    【解决方案1】:

    比较复杂

    set $var "q";
    if ($http_accept ~ application/xhtml\+xml) {
        set $var "q$var";
    }
    if ($http_accept !~ 'application/xhtml\+xml\s*;\s*q=0') {
        set $var "q$var";
    }
    if ($uri ~ \.html$) {
        set $var "q$var";
    }
    if ($server_protocol = HTTP/1.1) {
        set $var "q$var";
    }
    if ($var = qqqqq) {
        add_header 'Content-Type' 'application/xhtml+xml';
    }
    

    未测试

    【讨论】:

      猜你喜欢
      • 2016-08-09
      • 1970-01-01
      • 1970-01-01
      • 2011-04-16
      • 2021-04-04
      • 2016-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多