301重定向与复杂的目录正则表达式

编程入门 行业动态 更新时间:2024-10-13 08:20:13
本文介绍了301重定向与复杂的目录正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的文件夹重定向伟大的工程@ anubhava的解决方案。 301从一个目录重定向到另一个

I am using @anubhava's solution for folder redirect which works great. 301 redirect from one directory to another

我意识到,我还需要有一个301重定向以下

I realised that I also need to have a 301 redirect for the following

重定向

1) www.example/directory1/dirA/ 2) www.example/directory1/dirB/

重定向到

1) www.example/directory2/new-path-dirA/ 2) www.example/directory2/new-path-dirB/

编辑:我有很多这样的重定向(约40),想知道是否有办法有1重写规则 - 而不是单独的规则

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?

谢谢!

推荐答案

您可以添加这些新的规则:

You can add these new rules:

RewriteRule ^directory1/([^/]+)/(.*)$ /directory2/new-path-$1/$2 [NC,L,NE,R=301]

更多推荐

301重定向与复杂的目录正则表达式

本文发布于:2023-10-31 13:40:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   目录   正则表达式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!