My attempt to do this is…
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule \.js$ js.php [L] ## This line is the one I tried to add
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If I use a tag <script type='text/javascript' src='http://www.domain.net/myfile.js'></script> I would like it to go through js.php.
js.php
Will handle the file using header('....'); echo file_get_contents('myfile.js');
I have tried so many things to do this, I had done this before on a project but I can’t remember where now as I have to redo it 🙂
Hope it makes sense…
You can add the following rewrite rule :
In place of :
The result is :
Or you can do as follows :
The result is :
Some explanations about used RewriteRule flags :