【问题标题】:htaccess Rules convert to NGINX is not workinghtaccess 规则转换为 NGINX 不起作用
【发布时间】:2017-02-05 18:01:01
【问题描述】:

我想在 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;
}

有人可以帮助我吗? 非常感谢!

【问题讨论】:

    标签: apache .htaccess mod-rewrite nginx


    【解决方案1】:

    您不能在此处使用break。你应该使用last

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

    详情请见this document

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-17
      • 2017-07-15
      • 2015-09-09
      • 1970-01-01
      • 2014-11-07
      • 2018-09-01
      相关资源
      最近更新 更多