域重定向到另一个域在阿帕奇

问题描述:

有道我有这样的:域重定向到另一个域在阿帕奇

<VirtualHost *:80> 

    "DocumentRoot C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/mysite" 

    ServerName mysite.eu 

    ServerAlias www.mysite.eu 
    ServerAlias play.mysite.eu 

    ServerAlias www.mysite.org 
    ServerAlias play.mysite.org 
    ServerAlias mysite.org 

    DirectoryIndex index.php 

    Options -Indexes 

</VirtualHost> 

为什么这个没有自动跳转,从mysite.org所有请求mysite.eu?那么正确的做法是什么?

你有什么只有当有人去www.mysite.eu(然后需要指向服务器的IP)时使用,以便Web服务器知道使用虚拟主机文件来服务请求 - 即没有重定向。如果你想重定向,使用mod_rewrite,例如

RewriteCond %{HTTP_HOST} ^www\.mysite\.org$ [OR] 
RewriteRule ^.*$ "http\:\/\/www\.mysite\.eu" [R=301,L,QSA] 
+0

嗯,有些东西的战斗。当我把它放在这里时,我看到状态栏在最终放弃这条消息之前从mysite.org来回闪烁到mysite.eu:页面没有正确重定向 Firefox已经检测到服务器正在重定向请求这个地址的方式永远不会完成。 此问题有时可能由禁用或拒绝接受 Cookie引起。 – 2012-03-27 12:16:25

+0

这意味着你有一个无限的重定向循环 – scibuff 2012-03-27 12:44:36