问题
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