2013-03-08 48 views
0

這是我的.htaccess文件。重寫爲ip地址 - 網站不可用

RewriteCond %{HTTP_HOST} . 
RewriteCond %{HTTP_HOST} !^xxx\.xx\.xxx\.xx/domain\.com [NC] 
RewriteRule (.*) http://xxx.xx.xxx.xx/domain.com/$1 [R=301,L] 

網站不可用,這是錯誤,我得到:
The page isn't redirecting properly

如何創建這個重定向?

回答

1

嘗試與此

​​
+0

的'%{SERVER_ADDR}'是監聽套接字綁定到其處理請求的本地地址,它仍將如果請求的HTTP'做循環.xxx.xx/domain.com /' – 2013-03-08 22:50:22

2

%{HTTP_HOST}變量不包含在其中的任何URI路徑元件,它是被給定爲Host:請求報頭中的主機名替換

RewriteCond %{HTTP_HOST} !^xxx\.xx\.xxx\.xx/domain\.com [NC] 

。這通常是什麼出現在URL的主機名部分:

  • http://www.google.com/blahblahblah = www.google.com
  • http://localhost/foo/bar/zzzzz = localhost
  • http://123.45.67.89/something/something/ = 123.45.67.89

剛剛擺脫的來自y的所有URI我們的條件://xxx.xx:

RewriteCond %{HTTP_HOST} !^xxx\.xx\.xxx\.xx$ [NC] 
+0

+1再次感謝您的信息。 – 2013-03-09 00:50:56