redirect multiple pages with 301 htaccess

允我心安 提交于 2020-02-08 10:03:52

问题


I have about 3500 pages that will change URL because I need to remove one keyword from the URL. I will submit an updated sitemap to google but I would also like to provide htaccess 301 redirects for a while.

old url example "http://www.domain.com/my-old-url/" new url is "http://www.domain.com/my-url/"

old url example "http://www.domain.com/my-old-url-page/" new url is "http://www.domain.com/my-url-page/"

Keyword that needs to be removed is "old" and repeats itself across all url's.

Having 3500 individual 301 redirect lines in my htaccess would probably slow down my server and I don't think it's wise to do.

So I am asking what would be the best way to apply these 3500 redirects? Please provide code examples for your suggestions.

Thank you.


回答1:


You can just use a RedirectMatch rule here in your root .htaccess:

RedirectMatch 301 ^(.+?)-old(.*)$ /$1$2


来源:https://stackoverflow.com/questions/32667157/redirect-multiple-pages-with-301-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!