开发者

Problem with Apache rewrite rules. I want to redirect .com traffic to .co.uk

This is my current vhost.conf file:

<VirtualHost *:80>
    DocumentRoot /data/sites/mysite
    ServerName mysite.co.uk
    ServerAlias www.mysite.co.uk
    ServerName mysite.com
    ServerAlias www.mysite.com
    RewriteEngine On
    RewriteOptions inherit
    RewriteCond %{HTTP_HOST} !开发者_开发技巧^www\.mysite\.co\.uk|^www\.mysite\.com  [NC]
    RewriteCond %{HTTP_HOST} !^mysite\.co\.uk|^mysite\.com  [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*)        http://www.mysite.co.uk/$1 [L,R]
    CustomLog /var/log/httpd/mysite.log combined
</VirtualHost>

But I cannot get it to work properly. www.mysite.com is showing the mysite.co.uk website but the .com domain is still showing in the browser. Also if I go to www.mysite.com/myfiles it cannot find the folder that works on www.mysite.co.uk/myfiles

Any ideas?


Try this on the .com domain to redirect all requests to the co.uk

RewriteEngine On
RewriteRule ^(.*) http://yoursite.co.uk/$1 [R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜