简体   繁体   English

使用301 htaccess重定向多个页面

[英]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. 我大约有3500个页面将更改URL,因为我需要从URL中删除一个关键字。 I will submit an updated sitemap to google but I would also like to provide htaccess 301 redirects for a while. 我将向Google提交更新后的站点地图,但我还要在一段时间内提供htaccess 301重定向

old url example " http://www.domain.com/my-old-url/ " new url is " http://www.domain.com/my-url/ " 旧网址示例“ http://www.domain.com/my-old-url/ ”新网址为“ 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/ " 旧网址示例“ http://www.domain.com/my-old-url-page/ ”新网址为“ 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. 我的htaccess中有3500条单独的301重定向行可能会减慢我的服务器的速度,我认为这样做不明智。

So I am asking what would be the best way to apply these 3500 redirects? 因此,我想问一下应用这3500次重定向的最佳方法是什么? Please provide code examples for your suggestions. 请提供代码示例以提供您的建议。

Thank you. 谢谢。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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