'AddType / AddHandler Not Working
I'm working on a mac running OS X Lion and PHP 5.3.6 and have tried both AddType, AddHander, and AllowOverride has been set to ALL in the httpd.conf; however, the PHP codes in HTML/JS/CSS files are still parsed as text. Files ending with .php are all good. I'm now getting really desperate after hours of googling.
Here are the contents of my .htaccess file:
AddType application/x-httpd-php5 .html .js .css
AddType application/x-httpd-php .html .js .css
AddHandler application/x-httpd-php5 .html .js .css
AddHandler application/x-httpd-php.html .js .css
Solution 1:[1]
If your site is stored in your user's Sites folder (i.e. /Users/username/Sites/) then you also need to set AllowOveride in the user-specific configuration file in /etc/apache2/users/username.conf. After making the change restart apache by disabling and re-enabling Web Sharing in the Sharing preference pane.
Solution 2:[2]
The AddType procedure (at least on Mac OS X Server) requires:
- one and only extension per line
no dots before the extension
AddType application/x-httpd-php php
Have a look at /private/etc/apache2/httpd.conf for running examples.
(You should also remove the AddHandler procedures.)
Solution 3:[3]
I ran into same problem and fixed with:
<Files ~ "\.(gif|htm|txt|css|jpg|png)$">
SetHandler default-handler
</Files>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dave |
| Solution 2 | Fabrice Boyer |
| Solution 3 | Andrew Ho |
