基于 url 匹配的重定向
我无法使用 mod 重写获取要重定向的特定 URL。我正在进行更多基本的重写,因此到目前为止,这一切都正常,所以我的 URL 有问题。
我在这里尝试了该字符串,它显示了模式的工作原理。
测试以下
RewriteCond %{HTTP_HOST} ^landed.at/component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate$
RewriteRule (.*) http://landed.at/itworked [L,R=301]
我事实上想拉出 criteria:5 和 jr_country:sri-lanka 来制作我的变量 所以我的网址将变成
http://landed.at/tours/sri-lanka - 旅游if criteria:5 和来自 jr_country 的 sri-lanka
我无法快速使用正则表达式,为什么我的基本搜索匹配没有发生?根据正则表达式,它应该找到条件并进行重写?
I can't get a certain URL to redirect using mod rewrite. I am getting more basic rewriting happening so this is functioning as far as that goes so there is a problem with my URL.
I tried the string here and it showed the patter works..
testing the following
RewriteCond %{HTTP_HOST} ^landed.at/component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate$
RewriteRule (.*) http://landed.at/itworked [L,R=301]
I would like in fact to pull the criteria:5 and jr_country:sri-lanka out to make my variables
so my url would become
http://landed.at/tours/sri-lanka - tours if criteria:5 and sri-lanka from the jr_country
I'm getting no where fast with regex and why doesn't my basic search match happen? according to regexpal it should find the condition and do the rewrite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经包含了包含斜杠的完整路径,但您只是针对
HTTP_HOST
进行测试,该路径只是landed.at
。您想使用REQUEST_URI
吗? (这还必须包括http://
。)我建议可以使用普通的旧重定向来更干净地完成此操作。除非您确实需要它,否则不要将 mod_rewrite 的瑞士军电锯拖到游戏中。例如:
You have included a full path including slashes, but you are only testing it against the
HTTP_HOST
which will be justlanded.at
. Did you mean to useREQUEST_URI
? (That would have to include thehttp://
also.)I'd suggest this can probably be done more cleanly with plain old redirects. Don't drag the Swiss Army Chainsaw that is mod_rewrite into the game until you really need it. eg: