The setup is much simpler than it may seem: I have two (or more) sites...
http:// localhost/site1/
http:// localhost/site2/
They are very similar in how they are constructed so I wish to share the asset files between them. That means if I make a change to the asset files (e.g. JavaScript, CSS, images, etc) then those changes apply to all the sites.
For once I've actually have had success reading Apache's documentation in regards to the
QSA flag.
So I was able to have Apache have files here...
http:// localhost/scripts/*
...accessed this way...
http:// localhost/site1/scripts/*
http:// localhost/site2/scripts/*
...or to be more specific
http:// localhost/scripts/index.js
...can be accessed at....
http:// localhost/site1/scripts/index.js
There are some issues though. I'm having difficulty having Apache allow PHP to execute in this manner and sometimes it'll ask me to download the JavaScript file if I request it directly. I don't think PHP is being executed.
Also except for the exceptions and the script directory rule (and there will likely be other directories I have the exact same rule for) I think the order of the rules is rewriting everything to the target file instead of when I specify the script* directory/files.
So here is the code I have now (only difference is the the extensions in the exception list has been reduced for posting)...
http:// 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
So what I want is that unless a request goes to scripts* or themes* or has a matching extension that it be handled by http:// localhost/rewrite.php. I also need to have PHP execute in certain file types as well. I've rearranged the rules, have tried putting the JavaScript/PHP association in
scripts/.htaccess separately etc. I'm either remarkably close or really not, help please?
- John