Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Apache 2.0, PHP 5.2.4, and this directive in the httpd.conf:

AddType application/x-httpd-php-source .php .php3 .php4 .php5 .php6

AddType directive is used to maps the given filename extensions onto the specified content type. This is the only meaning of this directive. But why does this method switch off PHP handler, that assigned .php extensions, and I can view source code of scripts in my browser?

And another:

AddType application/x-httpd-php5 .php

Why does this method switch on PHP handler? This simply must send header Content-Type: application/x-httpd- to my browser and this must be only meaning of directive AddType from mod_mime.

I'm confused.

share|improve this question

The AddType directive should only affect the clients interpretation of what your sending it. A common one that is used is text/html which most clients will readily accept and interpret for what you want. Different browsers like I.E. Firefox and Chrome can sometimes interpret these headers differently.

A corollary command is AddHandler which affects how the server interprets the scripts.

Your question is a bit difficult to understand. Are you stating that when you use AddType application/x-httpd-php-source .php .php3 .php4 .php5 .php6 that you can see the actual PHP code itself rather than the processed HTML, but with AddType application/x-httpd-php5 .php it works?

share|improve this answer
Josh, yes, you understand correct. My Apache works in this way. And I did not touch [b]AddHandler[/b] – egor Sep 11 '10 at 4:49

You should only add this directive to .phps or whatever name you have to php source files you want shown with syntax highlighting, not the ones you want interpreted. If you want the .php{3,4,5,6} to work normally, add it to the correct handler x-httpd-php. There's no way to assign the same extension to both handlers and have it work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.