1

我有一大堆重复的网址,我需要做一些重定向

例子

www.mysite.com/mypage/name2_68.html   
www.mysite.com/jjj/name2_68.html   
www.mysite.com/aa/name2_68.html   
www.mysite.com/5654/name2_68.html   

www.mysite.com/mypage/myname87.html   
www.mysite.com/6584/myname87.html   
www.mysite.com/any-number/myname87.html   
www.mysite.com/any_word/myname87.html   

我需要做的就是将它们重定向到

www.mysite.com/mypage/myname87.html   
www.mysite.com/mypage/name2_68.html   

所以所有的网址

www.mysite.com/anycharactere/example1.html    

将被重定向到

www.mysite.com/mypage/example1.html
4

2 回答 2

1

这应该有效。

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !^/mypage/?
RewriteRule ^[^/]+/(.*\.html?)$ /mypage/$1 [R=301,L]
于 2013-05-28T20:53:13.157 回答
0

把它放在你的 .htaccess

RewriteEngine On
RewriteRule .*/([^/]+.html)$ /mypage/$1
于 2013-05-28T20:20:49.650 回答