2012-01-14 25 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/