2010-05-12 225 views
5

我在一個drupal站點上工作,我檢出(svn)到我的localhost。Drupal localhost重定向到www.localhost.com

現在的問題是,當我去:

http://www.site.com

這一切工作正常,但是當我去:

http://localhost/work/site

我被重定向到

http://www.localhost.com/work/site

我已經跑了install.php了腳本,所有的偉大工程。它會重新安裝所有內容,但是當我進入主站點時會發生重定向。

我刪除了.htaccess文件,沒有做任何事情。

我使用Windows 7反正最終64(也嘗試在WINXP PRO 32)的Apache 2.2,PHP 5.2.13

任何人都知道解決這一問題?

感謝

+0

你有任何機會的nod32殺毒軟件嗎? – iBiryukov 2010-05-12 21:05:51

+0

不! Avast在Windows 7 PC和Windows XP上沒有殺毒軟件 – AntonioCS 2010-05-12 21:09:44

+0

是Apache的運行?你有沒有試過香草Drupal安裝? – Robert 2010-05-12 21:57:32

回答

0

從Drupal的網站/默認/ settings.php這個文件:

/** 
* Base URL (optional). 
* 
* If you are experiencing issues with different site domains, 
* uncomment the Base URL statement below (remove the leading hash sign) 
* and fill in the absolute URL to your Drupal installation. 
* 
* You might also want to force users to use a given domain. 
* See the .htaccess file for more information. 
* 
* Examples: 
* $base_url = 'http://www.example.com'; 
* $base_url = 'http://www.example.com:8888'; 
* $base_url = 'http://www.example.com/drupal'; 
* $base_url = 'https://www.example.com:8888/drupal'; 
* 
* It is not allowed to have a trailing slash; Drupal will add it 
* for you. 
*/ 
# $base_url = 'http://www.example.com'; // NO trailing slash! 

嘗試設置$ BASE_URL = 'http://localhost/work/site';

+0

我已經完成了這個工作,但我仍然遇到同樣的問題 – AntonioCS 2010-05-13 09:12:54

2

你檢查了你的窗口的hosts文件嗎?不知道它生活的地方在Windows 7,但在XP它住在這裏:

C:\WINDOWS\system32\drivers\etc\hosts 

確保有這樣一個條目:

127.0.0.1  localhost 

作爲一個仔細檢查,你可能想刷新您的PC DNS緩存。進入命令行並鍵入:

ipconfig /flushdns 
+1

我有其他網站完美工作,所以這不是問題 – AntonioCS 2010-05-13 09:13:16

+0

如何離奇!如果不是這個或.htaccess/httpd.conf的問題,那麼我不知道它可能是什麼... – Mathew 2010-05-13 11:00:39

+0

我現在有同樣的isssue,這沒有幫助。它已經工作了6個月,今天Firefox正在解決www.localhost.com – stephenbayer 2011-05-24 12:31:47

0

我終於找到了背後這個巨大問題的原因。

這是CSS和JS優化,搞亂了一切。 我設置這兩個關閉,然後將數據庫複製到本地主機版本的網站,所有的工作出色!

+1

設置這兩個關閉意味着......?我怎麼能設置..? – 2013-10-22 06:46:05

12

重定向是由於Firefox無法獲得與本地服務器的良好連接,然後嘗試「修復」該地址而導致的。您可以如下禁用Firefox中的行爲:

  1. 在地址欄中鍵入about:config 並命中返回。
  2. 查找browser.fixup.alternate.enabled。
  3. 雙擊「true」值。該生產線將變得大膽和 值將改變爲「假」 from here

但是這不會解決你的根本問題(本地服務器沒有響應右),它只會擺脫真令人討厭的行爲。這種故障有幾種可能的原因,MatW建議的主機文件問題是一個常見原因。

在我的情況下,Drupal似乎在某些頁面加載過程中崩潰了Apache,當瀏覽器將您自己的頁面重定向到您需要刷新的頁面時,很難診斷/修復它。