我有一个重复网址的大列表,我需要做一些重定向
示例
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
答案 0 :(得分:1)
这应该有用。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/mypage/?
RewriteRule ^[^/]+/(.*\.html?)$ /mypage/$1 [R=301,L]
答案 1 :(得分:0)
将它放入.htaccess
RewriteEngine On
RewriteRule .*/([^/]+.html)$ /mypage/$1