mod_alias 重定向提示
全部。我搜索网站但找不到答案,所以我发布它。
我想像这个
example.com/css/.... ====> 一样重定向 url example.com/templates/css/...
example.com/path/css/.... ====> example.com/path/templates/css/...
我经常厌倦,但不是我希望的。比如
RedirectMatch (.*)/css/(.*)\.css $1/templates/css/$2.css
我认为最后一个常客也许是对的。但需要将常规设置为惰性模式。我找到了apache文档中关于mod_alias和mod_rewrite的内容,还没有找到谈论这个技巧的。
需要帮助。谢谢 !
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 !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过在
*
之后添加?
来实现惰性匹配,如下所示:*
然后尝试尽可能少地匹配。这应该会按照您的预期转换示例中的 url。顺便说一句:Apache mod_rewrite 是Perl 兼容的正则表达式,并添加了一些内容。
You get lazy match by adding
?
after*
, like this: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.
好吧,我检查了一下,我倾向于 reglar 断言功能 XD。
这对我来说非常有效。希望可以帮助一些人。
ok,I check it out , and I leaned reglar assert features XD.
this works very well for me . hope can help some people.