任何人都可以帮我将.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]
答案 0 :(得分:0)
试试这个htAccess to Nginx converter
# nginx configuration
location /category {
rewrite ^/category/(.)/(.).html$ /cat.php?cat=$2&page=$1 break;
rewrite ^/category/(.*).html$ /cat.php?cat=$1 break;
}
location /search {
rewrite ^/search/(.)/(.).html$ /search.php?cat=$2&page=$1 break;
rewrite ^/search/(.*).html$ /search.php?cat=$1 break;
}
location /others {
rewrite ^/others/(.)/(.)/(.*).html$ /other.php?cat=$3&page=$2&data=$1 break;
rewrite ^/others/(.)/(.).html$ /other.php?cat=$2&data=$1 break;
}
location /download {
rewrite ^/download/(.)-by-(.)-download.html$ /video.php?title=$1&artist=$2 break;
}
无论如何,你可以自己做,因为这些是简单的url格式重写规则。 例如在.htAccess
中RewriteRule ^category/(.)/(.).html$ /cat.php?cat=$2&page=$1 [QSA,L]
以上规则说明请求时采用以下网址格式
^ category /(。)/(。)。html $ (http://myhostname.com/category/[page-id]/[category-id].html)
将其重写为以下格式
/cat.php?cat=$2&page=$1 (http://myhostname.com/cat.php?cat=[category-id]&page=[page-id])
此规则转换为nginx如下
location /category {
rewrite ^/category/(.)/(.).html$ /cat.php?cat=$2&page=$1 break;
rewrite ^/category/(.*).html$ /cat.php?cat=$1 break;
}