Mod rewrite 将重写规则从htaccess转换为nginx

Mod rewrite 将重写规则从htaccess转换为nginx,mod-rewrite,nginx,Mod Rewrite,Nginx,任何人请帮助我将.htaccess中的以下规则转换为nginx RewriteEngine On RewriteRule ^category/(.*)/(.*).html$ /cat.php?cat=$2&page=$1 [QSA,L] RewriteRule ^category/(.*).html$ /cat.php?cat=$1 [QSA,L] RewriteRule ^search/(.*)/(.*).html$ /search.php?cat=$2&page=$1 [QS

任何人请帮助我将
.htaccess
中的以下规则转换为nginx

RewriteEngine On
RewriteRule ^category/(.*)/(.*).html$ /cat.php?cat=$2&page=$1 [QSA,L]
RewriteRule ^category/(.*).html$ /cat.php?cat=$1 [QSA,L]
RewriteRule ^search/(.*)/(.*).html$ /search.php?cat=$2&page=$1 [QSA,L]
RewriteRule ^search/(.*).html$ /search.php?cat=$1 [QSA,L]
RewriteRule ^others/(.*)/(.*)/(.*).html$ /other.php?cat=$3&page=$2&data=$1 [QSA,L]
RewriteRule ^others/(.*)/(.*).html$ /other.php?cat=$2&data=$1 [QSA,L]
RewriteRule ^download/(.*)-by-(.*)-download.html$ /video.php?title=$1&artist=$2 [QSA,L]
试试这个

无论如何,你可以自己做,因为这是简单的url格式重写规则。 例如在.htAccess中

RewriteRule ^category/(.)/(.).html$ /cat.php?cat=$2&page=$1 [QSA,L]
上面的规则说明当有以下url格式的请求时

^category/(.)/(.)html$()

将其改写为以下格式

/cat.php?cat=$2和page=$1()

这个规则转换为nginx,如下所示

location /category {
rewrite ^/category/(.)/(.).html$ /cat.php?cat=$2&page=$1 break;
rewrite ^/category/(.*).html$ /cat.php?cat=$1 break;
}

@德山:谢谢你的建议。但是我已经试过了。它不起作用。
location /category {
rewrite ^/category/(.)/(.).html$ /cat.php?cat=$2&page=$1 break;
rewrite ^/category/(.*).html$ /cat.php?cat=$1 break;
}