NGINX:永久删除部分网址
作者:互联网
我重新设计了一个网站并更改了网址格式.
现在我需要将旧网址更改为新网址.
这是我的旧网址:
http://www.example.com/forum/showPost/2556/Urgent-Respose
新网址将是:
http://www.example.com/2556/Urgent-Respose
如何通过从url中删除/ forum / showPost使用nginx重定向到新的URL?
编辑:
还有这个网址:
http://www.tikshare.com/business/showDetails/1/Pulkit-Sharma-and-Associates,-Chartered-Accountants-in-Bangalore
新网址:
http://www.tikshare.com/classifieds/1/Pulkit-Sharma-and-Associates,-Chartered-Accountants-in-Bangalore
上面的链接已完全删除,而此链接将用分类替换business / showDetails
解决方法:
server
{
listen 80; ## Listen on port 80 ##
server_name example.com; ## Domain Name ##
index index.html index.php; ## Set the index for site to use ##
charset utf-8; ## Set the charset ##
location ^~ /forum/showPost {
rewrite ^/forum/showPost(.*)$$1 permanent;
}
location ^~ /business/showDetails {
rewrite ^(.*)business/showDetails(.*)$classifieds$1 permanent;
}
}
标签:nginx,url-rewriting,nginx-location 来源: https://codeday.me/bug/20190828/1754188.html