Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the apache2.0, PHP5.2.4 and the 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-php5" to my browser and this must be only meaning of directive AddType from mod_mime. I'm confused.

Thanks for your replies.

share|improve this question
    
any other guesses –  egor Sep 15 '10 at 14:17
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.