Search code examples
regexmod-alias

mod_alias redirect tips


all. I search the sites but can not find my answer, so I post it.

I want to redirect url like this

example.com/css/.... ====> example.com/templates/css/...

example.com/path/css/.... ====> example.com/path/templates/css/...

I tired lots regular, not I wish. such as

RedirectMatch (.*)/css/(.*)\.css  $1/templates/css/$2.css 

I think the last regular maybe right. but need set regular to lazy-mode. I find the apache document about mod_alias and mod_rewrite, haven't found talk about this tips.

need help. thanks !


Solution

  • ok,I check it out , and I leaned reglar assert features XD.

    (^(t(?!emplates)|[^t])*?)/(css|js)/(.*)\.(css|js)$ $1/templates/$3/$4.$5
    

    this works very well for me . hope can help some people.