Jump to content

How do I force .js to be execute as a .php file?


megetron

Recommended Posts

Hi,

I have a file with a .js extension (I dont want to change the extensions because of other issues I have, wich are for another thread :) ).

 

in this .JS file I want to execute some php commands. actually I want to generate using php a .js file.

 

How do I do that?

If it were me, I would change the ext to .php and use the header content-type to force it back to javascript. 

 

Alternatively you could make the server parse all .js files as PHP, which is horrible IMHO.  Especially if you only have 1 file that needs parsing.

 

.htaccess

AddType application/x-httpd-php .js

 

You may even have to make that:

AddType application/x-httpd-php5 .js

if you are on a host like GoDaddy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.