redirect multiple pages with 301 htaccess

2019-09-17 10:02发布

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条回答
Ridiculous、
2楼-- · 2019-09-17 11:02

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

RedirectMatch 301 ^(.+?)-old(.*)$ /$1$2
查看更多
登录 后发表回答