开发者

Apache not handling files correctly (Handler Help)

开发者 https://www.devze.com 2023-01-03 16:20 出处:网络
I\'m trying to set up my .htaccess file correctly and I\'m having an issue. The only thing my .htaccess file at the moment is:

I'm trying to set up my .htaccess file correctly and I'm having an issue.

The only thing my .htaccess file at the moment is:

AddType application/x-httpd-php .php .html .htm

This is included because my server is not parsin开发者_如何学Pythong php in my html files.

However when this is included in my .htaccess file, when I open a page in my browser, the user is prompted to save or open the file locally.

I believe the answer to my issues is setting up an action to be done (run with php) however I cannot find out the path to my php files.

Any help is appreciated.


You will need to edit the configuration for enabled modules. On a Debian/Ubuntu type system this will be in /etc/apache2/mods-enabled The file you are looking for is php5.conf

So far all you have done is specify that (dot) htm, html or php files should be served -by default- as application/x-httpd-php, and to my knowledge there is not a single web browser that would attempt to interpret such content -- hence the save-as dialog.

Either you could fix your .htaccess file not to be broken (it is broken behaviour to serve html files as application/x-httpd-php), or you could manually output the correct HTTP headers using the PHP header() function.


Unfortunately, everyone seems to love abusing AddType (and then complain e.g. that MultiViews is broken). See this article, please.


This is not supposed to work in all cases. It depends on the AllowOverride directive of the web server.

You shoud specify the AddType in the serveur config file rather than in the htaccess.

0

精彩评论

暂无评论...
验证码 换一张
取 消