2013-02-21 30 views
1

將我們的Linux測試服務器從php 4升級到php 5後,服務器現在會提示用戶並嘗試在導航到test.domain時下載主頁-name.org。如果我專門指向索引文件,則沒有問題,頁面顯示正常。只有我們去test.domain-name.org纔會出現問題。這會生成一個下載提示。如果我導航到一個頁面特定的網址,如test.domain-name.org/index.html或test.domain-name.org/index.php,網頁加載正常。 Linux的人說他把服務器設置得和其他沒有問題的服務器一樣。作爲php的傢伙,我回復說我的代碼和mod_rewrite與我們其他沒有問題的網站完全相同。我能夠讀取phpinfo文件。 Apache版本是2.2.23。 PHP版本是5.3.21。我已閱讀其他帖子,但這個問題似乎是獨一無二的。這裏是我的主頁mod_rewrite的代碼在我的htaccess文件:服務器嘗試下載主頁 - 其他頁面/文件顯示正常

RewriteRule ^/?(index.html)?$ index.php [L] 
+0

嘗試'標題(「內容類型:text/html的; charset = YOUR-CHARSET')' – Peter 2013-02-21 17:21:49

+0

在apache檢查:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml – Satish 2013-02-21 17:32:06

+0

@Peter,謝謝,但它仍然在提示下載。我將該代碼放在php文件的頂部,將charset定義爲utf-8。 – B6431 2013-02-21 17:39:51

回答

1

檢查DirectoryIndex在Apache配置文件httpd.conf

# DirectoryIndex: sets the file that Apache will serve if a directory 
# is requested. 
# 
# The index.html.var file (a type-map) is used to deliver content- 
# negotiated documents. The MultiViews Option can be used for the 
# same purpose, but it is much slower. 
# 
DirectoryIndex index.html index.html.var index.php 

conf文件看起來是這樣的:

LoadModule php5_module /usr/lib/httpd/modules/libphp5.so 
AddType application/x-httpd-php .php 
DirectoryIndex index.php 

製作確定您的.htaccess文件中沒有IndexIgnore *網頁目錄:

讀到它IndexIgnore

有用的鏈接 IndexIgnore * or Options -Indexes

+0

同時檢查主Apache配置是否允許覆蓋索引。問題是,如果沒有文件名或結尾斜槓,將會提供Web服務器/瀏覽器未知內容類型的文件。 – 2013-02-21 17:42:30

+0

你有webroot中的.htaccess文件嗎? – Satish 2013-02-21 17:44:31

+0

是的,有一個htaccess文件,我有點確定它在根目錄中。另外,我有一個關於DirectoryIndex的問題。我們的httpd.conf文件中的DirectoryIndex比上面列出的文件擴展名多得多。如果我們僅限於上面列出的三種不同的文件類型,是否可能會結束下載提示?關於conf,我現在試着驗證我們的包含你上面的內容。 – B6431 2013-02-21 19:33:17

相關問題