Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Preventing viewing of PHP



1:02 pm on Mar 30, 2009 (gmt 0)

10+ Year Member

I have PHP-based sites which have been working fine.

The file extensions are .html, which Apache parses as PHP, as specified in httpd.conf ("AddType application/x-httpd-php .html" in a VirtualHost directive)

Today I noticed to my horror that if I access my site as

http: //

... the page is served as plain text (i.e. you can see unparsed PHP by looking at "View source") (!)

How do I prevent this happening?!

This happens with sites I've coded, but doesn't happen with my sites running Wordpress, so I'm guessing it's something simple but pretty fundamental that I've left out :-)


1:12 pm on Mar 30, 2009 (gmt 0)

10+ Year Member

- Don't set MIME-types (AddType) when you're tying to invoke a handler (use AddHandler instead)
- make sure there's a handler for handling application/x-httpd-php, i.e., the module mod_php is loaded or there's some other action defined (action directive, fastcgi or whatever).


1:23 pm on Mar 30, 2009 (gmt 0)

10+ Year Member

But would this explain the difference between:

- viewing the page normally (e.g. http: //www.sitename.com - which works)


- viewing it by IP address (e.g. http: // - where the PHP isn't parsed)?


3:36 pm on Mar 30, 2009 (gmt 0)

10+ Year Member

Other configuration/virtual host? Serving from the main server?

Featured Threads

Hot Threads This Week

Hot Threads This Month