2012-07-03 59 views
0

我有下面的规则完美的作品,但是我的老网站URL有.html和我的网站没有。是否有可能在重定向之前剥离.html文件?例如删除.html重定向之前Htaccess

www.oldsite.com/mypage.html

被重定向到

www.newsite.com/subdir/mypage/

例如

Options +FollowSymLinks 
RewriteEngine on 

RewriteCond %{HTTP_HOST} ^www.oldsite.com$ [NC] 
RewriteRule ^(.*)$ http://www.newsite.co.uk/subdir/$1 [R=301,L] 

回答

1
Options +FollowSymLinks 
RewriteEngine on 

RewriteCond %{HTTP_HOST} ^www.oldsite.com$ [NC] 
RewriteRule ^(.*)\.html$ http://www.newsite.co.uk/subdir/$1 [R=301,L] 

所以www.oldsite.com/mypage.html将被重定向到www.newsite.com/subdir/mypage