WebFaction
Community site: login faq

Hi,

Some months ago I thought I had this working and upon revisiting it seems it's not working at all. What I'm attempting to do is have some PHP get parsed in a JavaScript file.

.htaccess
<FilesMatch "^.?geoip.?$">
SetHandler php5-script
</FilesMatch>

get.geoip.js
<?php
header("Content-type: application/javascript");
//run some PHP and echo value into JS object code here
?>

I thought the above was once working but now I'm just seeing my PHP code when trying to view my JS file.

I tried some other directives but nothing actually seems to work...

#match all JS files and parse PHP, set org content type so it isn't needed to be manually called in each file
<FilesMatch ".js$">
SetHandler php5-script
SetHandler application/x-httpd-php
Header set Content-type "application/x-javascript"
</FilesMatch>

#match a specific JS file and parse PHP, set org content type so it isn't needed to be manually called in each file
<FilesMatch filename.js>
ForceType application/x-httpd-php
SetHandler php5-script
SetHandler application/x-httpd-php
Header set Content-type "application/x-javascript"
AddHandler application/x-httpd-php5 .js
</FilesMatch>

asked 30 Apr '14, 15:26

nehpets
1113
accept rate: 0%

edited 30 Apr '14, 15:29


With help from support the following directive solved my issue:

<FilesMatch "^.*geoip.js$">
SetHandler php54-fcgi
</FilesMatch>

permanent link

answered 30 Apr '14, 21:14

nehpets
1113
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×75
×13
×3

question asked: 30 Apr '14, 15:26

question was seen: 5,335 times

last updated: 30 Apr '14, 21:14

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM