2010-03-12 23 views
2

我使用動態IP地址運行Apache2 Web服務器。我購買了exampledomain.net,我使用no-ip.com的域更新服務將任何訪問者重定向到我當前的IP地址(尾註#1)。例如,某人訪問exampledomain.net並且他們被重定向到73.181.57.34。它像一個魅力。但是,這並不是所有的用戶友好的。我可以重寫重定向的IP地址網址嗎?重寫一個已被重定向的URL?

我嘗試了這些重寫規則在根文件夾的.htaccess ...

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^73\.181\.57\.34:88 
RewriteRule ^(.*)$ http://www.exampledomain.net/$1 [L,NC] 
# I simplified the RewriteCond. I would use regex in a real situation. 

當然,這將創建一個無限循環。用戶訪問www.exampledomain.net。通過no-ip將它們重定向到73.181.57.34:88。 Apache將它們重定向到www.exampledomain.net,它們將它們重定向回73.181.57.34:88 ...等等等等。

我是一個noob當談到重寫,但有沒有辦法重寫URL而不重定向?

我嘗試了這些重寫規則太(在黑暗中拍攝)...

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^73\.181\.57\.34:88 
RewriteRule ^(.*)$ my.exampledomain.net/$1 [L,NC] 
# I'd read that Apache replied with a redirect header when you include http 

當然,這並不工作,因爲my.exampledomain.net實際上並不存在。

謝謝!


(1)No-IP的工作方式如下:您可以在服務器上下載並安裝動態更新客戶端。每隔幾分鐘它就會輪詢服務器的當前外部IP地址。如果它改變了,它會在no-ip的記錄中更新你的服務器的IP地址。

回答