I have the following code in ://localhost/.htaccess…
AddType application/x-httpd-php5 .css .js
RewriteEngine on
RewriteRule .*\/scripts(.+) scripts$1 [QSA]
RewriteRule .*\/themes(.+) themes$1 [QSA]
RewriteRule !\.(css|xhtml|xml|zip)$ rewrite.php
Goal: To be able to use files in the ://localhost/scripts/ and ://localhost/themes/ directories for more than one site. Using the QSA flag I’ve been able to get both the directory and files (from both directories) to be accessible.
So…
://localhost/site1/scripts/
://localhost/site2/scripts/
…both access…
://localhost/scripts/
…and all the files in the directory as well of course.
The Problem: I’m not sure how to adapt the PHP execution in .js and .css files with this setup. In my current setup I have the files override the mime/media type using PHP. I have tried reordering the code around unsuccessfully so I’m not sure this is an order-of-execution problem. JavaScript files in example are being served as “application/x-httpd-php5” instead of actually executing PHP.
Clarifications
-
The rewrite rule for file extensions is truncated intentionally so ignore that.
-
This has absolutely nothing to do with redirects.
-
I have tried symbolic links however apparently the alias command only works in the server configuration.
-
Presume I have absolutely no access to the server configuration, I can only use .htaccess (I need to mirror this eventually in a live environment on shared hosting).
-
I have rearranged the commands and have even used separate .htaccess files in numerous combinations.
Turns out I somehow ended up mixing up AddHandler and AddType!