1

我有这样的永久链接网站:

_http://www.domain.com/read/o/one-url-posting/

_http://www.domain.com/read/t/two-url-posting/

_http://www.domain.com/read/f/four-url-posting/

_http://www.domain.com/read/s/six-url-posting/

_http://www.domain.com/read/n/nine-url-posting/

_http://www.domain.com/read/x/xxx-url-posting/

如何将所有永久链接重定向到 _http://www.domain.com/read/nine-url-posting/ 在“读取”后的斜线之间没有一个字符?

谢谢

4

2 回答 2

2

我从另一个网上找到了答案,就像这样。

location ~ ^/read/(.*)/(.*)/ {    
    return 301 /read/$2/;    
}

结案。谢谢

于 2014-09-29T00:21:50.970 回答
1

您是否需要将所有链接重写为 1 个链接或每个链接都指向同一个链接,但没有一个字符(x/xxx-url-posting/ -> xxx-url-posting/)?

第一种情况试试这个:

rewrite "^/read/([a-z]{1})/(.*)/$" /read/nine-url-posting/ last;

这是第二种情况:

rewrite "^/read/([a-z]{1})/(.*)/$" /read/$2/ last;
于 2014-09-28T18:18:46.733 回答