homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Preventing viewing of PHP

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

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)

- 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)

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)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved