将apache htaccess重写规则转换为nginx重写规则

时间:2014-05-13 08:20:07

标签: apache .htaccess nginx rule

有人可以帮我转换nginx的规则吗?我需要它在FireFox中为svg掩码提供html作为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]

1 个答案:

答案 0 :(得分:0)

它更复杂

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';
}

未经测试