I am newbie with Apache's mod_rewrite
and I'm having some difficulties getting it to do what I want.
In my static directory, I have some javascript files (.js
) with 2 kind of filename:
xxxx.js
which is the standard file nameAT_xxxx.js
(with prefixed filename) which has been duplicated from previous standard file name but also contains my customizations
I would like to parse requests for each standard requested javascript file (xxxx.js
) to check if a customized file exists (AT_xxxx.js
) including all sub-directories. Then, in this case, use the custom file instead of the standard file (perhaps by internal redirect).
I tried to figure this out for hours but something is still wrong.
Note: Also, I don't know how to find custom files in sub-directories.
DocumentRoot "/data/apps/dev0/custom/my_static"
<filesMatch "\\.(js)$">
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/AT_$1.js -f
RewriteRule ^(.*[^/])/?$ %{DOCUMENT_ROOT}/AT_$1.js [QSA,L]
</filesMatch>