Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Apache not serving PHP files after nameserver change

3:20 pm on Mar 12, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 18, 2008
posts: 73
votes: 0

I am having an issue where we originally had a site up and running using the default domain that the host provided us. Yesterday I began to point our main example.com domain to the new webhost. Since it began switching when I try to visit the site in any browser I get a prompt telling me:

"You have chosen to open

which is a: application/x-httpd-php
from: http://example.com

what should firefox do with this file?"

I have tried restarting both apache and the server. .htaccess directives(these worked before the nameserver change):

RewriteEngine on
RewriteBase /
Options -Multiviews
DirectoryIndex index.htm index.html index.php

# Use PHP5 as default
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php

to get the site to stop doing this when it was the default domain, but now they seem to have no effect.

In my httpd.conf file I have the following:

<VirtualHost example.com>

DocumentRoot "/var/www/host/example.com/httpdocs/"
<Directory "/var/www/host/example.com/httpdocs/">
Options FollowSymLinks
AllowOverride All
Order deny,allow
allow from all

Any ideas? Thanks so much for any help.
12:18 am on Mar 18, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

If the "default domain" was configured separately under the control of your hosting company, then the easiest thing to do might be to request a copy of the VirtualHost section their default httpd.conf file -- the one that they used to configure your "default domain." Then modify it as you wish.

It looks like the set-up for scripting support is missing from your custom config file, and very likely there are other things missing as well.

Also, consider moving your .htaccess directives to a <Directory /> container in httpd.conf once you get them debugged -- there is a sometimes-quite-large performance advantage to this, but comparatively few webmasters have this option because they don't have server config access and so are forced to use .htaccess. Directives in config files are "compiled" once at server restart, whereas directives in .htaccess are "interpreted" for each and every HTTP request to the server. A comparison with a pre-compiled "C" executable versus an interpreted PERL script would be fair... Also, if all .htaccess directives can be moved to a config file, then you can use AllowOverride None. Then no per-request directory-walks will be required, and no .htaccess files will be fetched -- a further performance improvement (and reduces disk usage as well).