4

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.

0

2 Answers 2

4

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?

1
  • Josh, yes, you understand correct. My Apache works in this way. And I did not touch [b]AddHandler[/b]
    – egor
    Sep 11, 2010 at 4:49
2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .