.htaccess 到 nginx 重写

.htaccess 到 nginx 重写

请帮助我将这个 .htaccess 改为 rginx rewite

RewriteRule   ^show.php/(.*)$ show2.php?img=$1 [L]
RewriteRule   ^out.php/([a-z]{1})(.*)$ out2.php?$1=$2&%{QUERY_STRING} [L]
RewriteRule   ^view.php/(.*)$ view2.php?img=$1 [L]
RewriteRule   ^images.php/([a-z]{1})(.*)$ images2.php?$1=$2&%{QUERY_STRING} [L]

RewriteRule   ^gallery/([0-9]+)-([^/]*)/(.*)$ gallery.php?gal=$1&img=$3 [L]
RewriteRule   ^view/([0-9]+)-([^/]*)/(.*)$ gallery_body.php?gal=$1&img=$3 [L] 

答案1

我已经完成了这些,但我无法测试它们:

您需要在 Nginx 中包含 /。

阿帕奇

RewriteRule ^show.php/(.*)$ show2.php?img=$1 [L]

Nginx

Rewrite ^/show.php(.*)$ /show2.php?img=$1 last;

Nginx,query-string-append 是隐式的,因此没有特殊的语法。

阿帕奇

RewriteRule ^out.php/([a-z]{1})(.*)$ out2.php?$1=$2&%{QUERY_STRING} [L]

Nginx

Rewrite ^/out.php/([a-z]{1})(.*)$ /out2.php?$1=$2 last;

其余规则似乎是上述规则的变体。

安德鲁

相关内容