如何停止.htaccess重写重定向到html文件夹?

时间:2009-09-22 12:34:02

标签: .htaccess mod-rewrite redirect cross-domain directory-structure

我在MediaTemple上主持。

我希望 www.rhapsodicmusic.com 重定向到 www.rhapsodicmusic.co.uk 以便 www.rhapsodicmusic.com/anypageordirectory 将转到 www.rhapsodicmusic.co.uk/anypageordirectory

我的.htaccess

中有以下代码
RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^([^.:]+\.)*rhapsodicmusic\.com\.?(:[0-9]*)?$ [NC]
RewriteRule ^(.*)$ http://www.rhapsodicmusic.co.uk/$1 [R=301,L]

但是,此重定向规则会将 rhapsodicmusic.com 的所有内容发送到 rhapsodicmusic.co.uk/html ,例如 rhapsodicmusic.com/test.html 转到 rhapsodicmusic.co.uk/html/test.html ...

目录结构是:

域/
| - rhapsodicmusic.com/
| - | - cgi-bin /
| - | - html /
| - | - .htaccess
| - rhapsodicmusic.co.uk/
| - | - cgi-bin /
| - | - html /
| - | - | - index.html
| - | - | - about.html
| - | - | - 等......

如何阻止它重定向到那个(不存在的)html目录?

2 个答案:

答案 0 :(得分:0)

尝试此规则:

RewriteCond %{HTTP_HOST} ^(www\.)?rhapsodicmusic\.com$ [NC]
RewriteRule ^ http://www.rhapsodicmusic.co.uk%{REQUEST_URI} [R=301,L]

答案 1 :(得分:0)

感谢Gumbo,我刚刚开始工作的是:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ http://www.rhapsodicmusic.co.uk%{REQUEST_URI} [L,R=301]

这似乎工作得很好......