1

After an upgrade on our Linux test server from php 4 to php 5, the server now prompts the user and tries to download the home page when we navigate to test.domain-name.org. If I specifically point to the index file, there are no problems and the page displays fine. The problem only arises if we go to just test.domain-name.org. This generates a download prompt. If I navigate to a page specific url like test.domain-name.org/index.html or test.domain-name.org/index.php, the page loads fine. The Linux guy says he set the server up the same as are other servers which have no issue. Being the php guy, I replied that my code and the mod_rewrite are identical to our other sites which have no issues. I am able to read a phpinfo file. Apache version is 2.2.23. PHP version is 5.3.21. I have read other posts but this issue seems unique from the others. Here is my mod_rewrite code for the home page on my htaccess file:

    RewriteRule ^/?(index.html)?$ index.php [L]
B6431
  • 317
  • 1
  • 4
  • 13
  • try `header("Content-Type:text/html; charset=YOUR-CHARSET')` – Peter Feb 21 '13 at 17:21
  • in apache check: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml – Satish Feb 21 '13 at 17:32
  • @Peter, thanks but it is still prompting for a download. I placed that code at the top of the php file defining the charset as utf-8. – B6431 Feb 21 '13 at 17:39

1 Answers1

1

Check DirectoryIndex in apache configuration file 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 

The conf file looks like this:

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

Make sure you don't have IndexIgnore * in your .htaccess file at web directory:

Read about it IndexIgnore

Useful link IndexIgnore * or Options -Indexes

Community
  • 1
  • 1
Satish
  • 16,544
  • 29
  • 93
  • 149
  • Also check if the master Apache config allows overriding indexes. The problem is that without a file name or trailing slash, a file with a content type unknown to the web server/browser is being served. – Akber Choudhry Feb 21 '13 at 17:42
  • do you have .htaccess file in webroot? – Satish Feb 21 '13 at 17:44
  • Yes, there is an htaccess file and I am somewhat sure that it is in the root directory. Also, I have a question about DirectoryIndex. The DirectoryIndex in our httpd.conf file has a lot more file extensions than what you have listed above. If we restricted it to just the three different file types that you have listed above, could that potentially end the download prompt? About conf, am now trying verify that ours contains what you have above. – B6431 Feb 21 '13 at 19:33
  • You can keep other options in DirectoryIndex just make sure you have index.html & index.php. also what you have in .htaccess file? – Satish Feb 21 '13 at 19:37
  • In .htaccess `IndexIgnore * Options-Indexes Rewrite Engine On` Here is the pattern for other pages: `RewriteRule ^filename.html?$ filename.php [L]` The code is simple. – B6431 Feb 21 '13 at 20:33
  • 1
    I would say remove .htaccess file for just a TEST to see what happening.. also read http://stackoverflow.com/questions/14062641/indexignore-or-options-indexes – Satish Feb 21 '13 at 20:51
  • 1
    @Satish, your answer was correct regarding .htaccess. I read your recommended post using IndexIgnore *. I removed IndexIgnore * and problem solved. No more download prompts. There is a second .htaccess file that was placed inside a sub directory. I am guessing that using the two .htaccess files and IndexIgnore * is what created the problem. If you want to change your answer, I'll select it as the accepted answer. Much obliged. – B6431 Feb 22 '13 at 19:35
  • Great! I have just edited my answer and add suggested solution: – Satish Feb 22 '13 at 20:33