【问题标题】:Rewrite parts of SEO friendly URL in Nginx在 Nginx 中重写部分 SEO 友好 URL
【发布时间】:2017-03-21 18:01:33
【问题描述】:

我有一个类似这个例子的 URL

http://www.example.com/city/new-york/company-name

和

http://www.example.com/contact/new-york/company-name

是否可以将我的网址设为此网址?

http://www.example.com/new-york/company-name

和

http://www.example.com/new-york/company-name/contact

我的真实网址是

http://www.example.com/city.php?city=new-york&company=company-name

和

http://www.example.com/contact.php?city=new-york&company=company-name

【问题讨论】:

  • 有可能,你试过什么?
  • 不知道,我试试看有没有可能。

标签: php nginx url-rewriting seo


【解决方案1】:

试试这些规则,

rewrite ^contact/([\w-]+)/([\w-]+)$ contact.php?city=$1&company=$2;

rewrite ^city/([\w-]+)/([\w-]+)$ city.php?city=$1&company=$2;

在您的 location / 指令中。

【讨论】:

    猜你喜欢
    • 2015-07-30
    • 1970-01-01
    • 2021-07-06
    • 2015-01-04
    • 1970-01-01
    • 2012-03-03
    • 2015-02-24
    • 1970-01-01
    • 2011-03-02
    相关资源
    最近更新 更多