简体   繁体   中英

redirect multiple pages with 301 htaccess

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.

您可以在根.htaccess中仅在此处使用RedirectMatch规则:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM