开发者

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 !


You get lazy match by adding ? after *, like this:

(.*?)/css/(.*?)\.css

The * then tries to match as little as possible. This should transform the urls in your example as you expect.

By the way: Apache mod_rewrite is Perl compatible regular expression with some additions.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜