What is the difference between AddHandler and AddType in htaccess files

Can someone explain what is the difference between AddType and AddHandler in htaccess files? I want to configure such parameters so that I can run the javascript file (.js) through the server, as if it were a php file (application / x-httpd-php5), but then it was sent to the user's browser as (text / javascript). How can I customize this?

+4
source share
2 answers

I do not really like to parse all .js files as php. I would suggest using the .htaccess Rewrite directive to map .js files to your php script.

RewriteRule /phpjs/.* /phpjs/js.php 

Then add

 header("Content-Type: text/javascript"); 

to your php output.

+1
source

AddHandler http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addhandler tells the server how to handle the file type. AddType http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addtype tells the server which type of MIME to provide to the client.

+5
source

Source: https://habr.com/ru/post/1342650/


All Articles