redirect - 301重定向目录匹配

标签 redirect seo

我一直无法得到这个问题的答案。基本上,我有一堆网址,它们是这样的:

  • www.mysite.com/gb/best-price/description.shtml
  • www.mysite.com/fr/best-price/description.shtml
  • www.mysite.com/jp/best-price/description.shtml

我需要将他们重定向到他们的直接匹配页面,如下所示:

  • www.mysite.com/gb/best-price/index.shtml
  • www.mysite.com/fr/best-price/index.shtml
  • www.mysite.com/jp/best-price/index.shtml

我知道我可以做一对一的重定向,但事实是,我有数百个这样的 url.. 如何让重定向与目标 url 批量匹配,而不做一对一的重定向1?例如,/gb/best-price/description.shtml 到/gb/best-price/index.shtml

基本上,gb 到 gb,fr 到 fr,jp 到 jp。新旧 url 的唯一区别是 html 文件名(原始 url 以 description.shtml 结尾,新 url 以 index.shtml 结尾)。

谢谢, 亚历克斯

最佳答案

你可以尝试:

location / {
rewrite ^/(.*)/best-price/description.shtml ^//1/best-price/index.shtml permanent;

我认为它可以帮助你。 !!

关于redirect - 301重定向目录匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37249189/

相关文章:

javascript - 使用 Javascript 重定向页面,例如 PHP 的 Header->Location

seo - 如何知道 HTTP 请求是否是 BOT

asp.net-mvc - ASP.NET MVC URLs - 正确的方法

angular - Google 可以索引并跟踪 RouterLink 链接吗?

php - 使用户无法访问 'sitemap.xml',但机器人可以访问

apache - 通过IP访问网站时如何将网站重定向到其域名-CentOS?

ruby-on-rails - 使用 Mechanize Ruby 检测重定向到特定 IP

bash - 此重定向 ">>& <filename>"在 Korn shell 中是否有效?

.htaccess - 将所有 http 流量重定向到 https

ajax - 什么是隐身