如何使用nginx和php编写漂亮的永久链接


How to write pretty permalinks using nginx and php

我正在为我的一个客户网站"example.com"开发自定义RSS提要,为此,提要url采用查询字符串来自定义像这样的提要

http://example.com/feeds/rss_feed.php?num=20&store=2998 

我想把这些网址转换成

http://example.com/feeds/rss_feed.php/php/num/20/store/2998/ 

如果能在这件事上提供任何帮助,我们将不胜感激。

您必须在站点配置中创建额外的部分。不要忘记在做出更改后重新启动nginx。

location ~* ^/feeds/rss_feed.php/(.*)$ {
rewrite ^/feeds/rss_feed.php/php/num/('d+)/store/('d+)/$ /feeds/rss_feed.php?num=$1&store=$2 last;
}