Webhosting Blog

Parsing .js as .php


You can parse the .js file as .php using a simple code as follows in the .htaccess file.

Follow following steps:

1) [root@server ~]# cd /home/USER/public_html

2) [root@server ~]# vi .htaccess

3) Insert following code to parse all .js files as .php:

If the  Server has php5 installed use:

AddHandler application/x-httpd-php5 .js

If the  Server has php4 installed use:

AddHandler application/x-httpd-php4 .js

4) Save and quit the file. Also check if .htaccess is having proper ownership assigned.

5) Its done. Now you can parse all the .js files as .php

6) If you want to parse a single file you can follow following code in .htaccess.

<FilesMatch “testfilename.js”>
AddHandler application/x-httpd-php5 .js
</FilesMatch>

Note: testfilename.js ==>> indicates the .js file you would like to parse as .php.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s