Forum Moderators: phranque

Message Too Old, No Replies

Domain indexes not getting parsed for vhosts

PHP files get loaded everywhere except www.domain.com/index.php

         

wiltzius

7:56 pm on Dec 29, 2007 (gmt 0)

10+ Year Member



Hey all,

I'm having a really strange problem I'm hoping someone can help me with. I recently upgraded Apache and PHP on my box, and *almost* everything still works... just one catch: index.php files don't get parsed when they're the index of a virtually hosted domain. If I load the page directly, i.e. go to www.domain.com/index.php, then it works fine. And if it's in any other folder, such as www.domain.com/subfolder/ then it works fine as well -- DirectoryIndex kicks in to load index.php, the AddType rule applies and the .php file gets loaded. But if I just go to www.domain.com, the browser wants to download the source instead. It's behaving like it doesn't have the AddType rule for php files, but it clearly does because *everywhere* else it worked.

Googling on the subject has revealed only one really cryptic forum post somewhere that claimed someone had the same problem and resolved it by changing their UseCanonicalName to "off", but this doesn't seem to have any effect (nor do I really understand what it would do).

The only relevant httpd.conf lines I can think of are the AddType and DirectoryIndex ones:

AddType application/x-httpd-php .php

<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>

The virtual host declaration is really simple, so I don't think anything is getting overwritten:

<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /usr/www/domain
</VirtualHost>

This is on a FreeBSD box, running Apache 2.2.4 with PHP 5.2.1 running as an Apache module. Any other needed info I'll gladly provide. I'm pulling my hair out trying to figure this one out -- any ideas are greatly appreciated, thanks!

wiltzius

2:46 am on Dec 30, 2007 (gmt 0)

10+ Year Member



I was changing something unrelated and accidentally fixed the problem. I'm not entirely sure how, but I was rearranging my vhosts file and when I went to test everything, suddenly this worked. I think it may have been because now the vhosts are declared before the AddType declaration, not after, although I can't see why that would affect only this one weird case...