[英]301 redirect with complex directory regex
I am using @anubhava's solution for folder redirect which works great. 我正在使用@anubhava的文件夹重定向解决方案,效果很好。 301 redirect from one directory to another
301从一个目录重定向到另一个目录
I realised that I also need to have a 301 redirect for the following 我意识到我还需要针对以下内容进行301重定向
REDIRECT FROM 重定向自
1) www.example.com/directory1/dirA/
2) www.example.com/directory1/dirB/
REDIRECT TO 重定向至
1) www.example.com/directory2/new-path-dirA/
2) www.example.com/directory2/new-path-dirB/
EDIT: I have a lot of these redirects (about 40) and was wondering if there is way to have 1 Rewrite rule - instead of separate rules? 编辑:我有很多这样的重定向(大约40),并且想知道是否有办法具有1个重写规则-而不是单独的规则?
Thanks! 谢谢!
您可以添加以下新规则:
RewriteRule ^directory1/([^/]+)/(.*)$ /directory2/new-path-$1/$2 [NC,L,NE,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.