Saravana Prakash Saravana Prakash - 1 month ago 5x
Apache Configuration Question

Need help writing a RewriteRule to strip selectors in URL

I need to write a simple rewriterule in apache for 2 conditions

  1. Remove date selector from the js name

  2. change the location /js/ into /jsmin/

Input URL:

Output URL:

I tried below Rule:

RewriteRule ^/etc/designs/myapp/clientlibs/basefooter/js/(.*).(0-9).js /etc/designs/myapp/clientlibs/basefooter/js/$1.js
RewriteRule ^/etc/designs/myapp/clientlibs/basefooter/js/(.*).js /etc/designs/myapp/clientlibs/basefooter/jsmin/$1.js


  • All js are under /etc/designs/myapp/clientlibs/basefooter/js and get
    minified by maven during build into /jsmin

  • There are more sub directories under js like /js/foresee/foresee.js

It works for the second rule, but first rule fails. Can you please help to write the rule?


Your regex needs to be modified



  1. First group of brackets would match the folder and file name /etc/designs/myapp/clientlibs/basefooter/js/foresee/foresee-trigger.20160819.js
  2. Second group of brackets would match the date /etc/designs/myapp/clientlibs/basefooter/js/foresee/foresee-trigger.20160819.js