简体   繁体   English

.htaccess 301 仅重定向 1 个文件夹

[英].htaccess 301 redirect 1 folder only

I'm working on a WordPress site.我在一个 WordPress 网站上工作。

I want to 301 redirect all of these links我想 301 重定向所有这些链接

example.com/ a > example.com/ b example.com/ a > example.com/ b

example.com/ a /level1/level2 > example.com/ b /level1/level2 example.com/ a /level1/level2 > example.com/ b /level1/level2

example.com/ a /level1/level2/?productid=123 > example.com/ b /level1/level2/?productid=123 example.com/ a /level1/level2/?productid=123 > example.com/ b /level1/level2/?productid=123

However, I don't want to affect example.com/ c , example.com/ d , example.com/ e , etc.但是,我不想影响 example.com/ c 、 example.com/ d 、 example.com/ e等。

How would I go about 301 redirecting all of the a traffic to b?我将如何处理 301 将所有 a 流量重定向到 b 的问题?

Just place this redirect rule below RewriteEngine On line:只需将此重定向规则放在RewriteEngine On下方即可:

RewriteEngine ^a(/.*)?$ /b$1 [L,NC,NE,R=301]

Query string will be automatically forwarded to new URL.查询字符串将自动转发到新的 URL。

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

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