2016-04-15 39 views
0

我要做到这一点,其具有以下结构301重定向 - .gtaccess中的preg匹配规则?

http://www.example.com/hair-removal/ 
http://www.example.com/hair-removal/sub 
http://www.example.com/hair-removal/sub/supersub 

所有链接重定向到

http://www.example.com/hair-removal-new/ 
http://www.example.com/hair-removal-new/sub 
http://www.example.com/hair-removal-new/sub/supersub 

如何与一个htaccess文件实现这一目标?

回答

1

如果你只是想对/hair-removal/*并保留其他网址不变,使用:

RewriteRule ^hair-removal/(.*)$ /hair-removal-new/$1 [R=301,L] 
0

试试:

RewriteRule ^([^/]+)/ $1-new/ [R=301,NC,L]