2016-04-15 35 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]