2012-01-14 26 views
0

我有2个网址说thinkingmonkey.methinkingmonkey.com都具有IP地址127.0.0.1(A.K.A本地主机)。的mod_rewrite`Redirect`怎么样?

我想对任何thinkingmonkey.com请求重定向到thinkingmonkey.me

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot /mysite 
    ServerName thinkingmonkey.me 
    ServerAlias www.thinkingmonkey.me 
    ErrorLog logs/dummy-host.example.com-error_log 
    CustomLog logs/dummy-host.example.com-access_log common 
    Options -Indexes +FollowSymLinks 
    RewriteEngine On 
</VirtualHost> 


<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName thinkingmonkey.com 

    Redirect thinkingmonkey.com http://thinkingmonkey.me/ 

    # Redirect/http://thinkingmonkey.me/ #have even tried this 

    ServerAlias www.thinkingmonkey.com 
    RewriteEngine on 
</VirtualHost> 

当我尝试访问thinkingmonkey.com URL不重定向到thinkingmonkey.me。在布劳尔的地址栏中的网址仍然thinkingmonkey.com

我在做什么错?

+1

* *所以很多重复。 – 2012-01-15 08:44:37

回答

1

的mod_rewrite被认为是更好,更强大的处理这些重写。您可以使用下面的代码:

Options +FollowSymLinks -MultiViews 
RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(.*\.)?thinkingmonkey\.com$ [NC] 
RewriteRule^http://%1thinkingmonkey.me%{REQUEST_URI} [L,R=301] 

如果你真的,真的想使用mod_aias你可以把这个线的thinkingmonkey.comVirtualHost部分:

Redirect 301/http://thinkingmonkey.me/