htaccess规则转换为NGINX不起作用

时间:2016-09-27 23:42:11

标签: apache .htaccess mod-rewrite nginx

我想在NGINX中转换这些简单的规则,我使用这个网站(https://winginx.com/en/htaccess)来转换我的规则,但不知何故,当我点击它时,而不是去页面下载页面。

以下是示例:

我想将这些规则转换为NGINX:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^play/(.*)$ play.php?show=$1 [L]
RewriteRule ^category/(.*)$ category.php?show=$1 [L]
RewriteRule ^contact/(.*)$ contact.php [L]
RewriteRule ^contact$ contact.php [L]
RewriteRule ^terms/(.*)$ terms.php [L]
RewriteRule ^terms$ terms.php [L]

以下是该网站给我的信息:

# nginx configuration
location /play {
rewrite ^/play/(.*)$ /play.php?show=$1 break;
}
location /category {
rewrite ^/category/(.*)$ /category.php?show=$1 break;
}
location /contact {
rewrite ^/contact/(.*)$ /contact.php break;
}
location = /contact {
rewrite ^(.*)$ /contact.php break;
}
location /terms {
rewrite ^/terms/(.*)$ /terms.php break;
}
location = /terms {
rewrite ^(.*)$ /terms.php break;
}
有人可以帮帮我吗? 非常感谢!

1 个答案:

答案 0 :(得分:1)

您无法在此处使用break。您应该使用last

break的目的是在当前位置块内继续处理。在上述每种情况下,您都需要处理以移至location \.php$块。

有关详细信息,请参阅this document