基于 url 匹配的重定向

发布于 2024-12-07 17:31:43 字数 708 浏览 1 评论 0原文

我无法使用 mod 重写获取要重定向的特定 URL。我正在进行更多基本的重写,因此到目前为止,这一切都正常,所以我的 URL 有问题。

我在这里尝试了该字符串,它显示了模式的工作原理。

http://regexpal.com/

测试以下

   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..

http://regexpal.com/

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡忘如思 2024-12-14 17:31:43

您已经包含了包含斜杠的完整路径,但您只是针对 HTTP_HOST 进行测试,该路径只是 landed.at。您想使用 REQUEST_URI 吗? (这还必须包括 http:// 。)

我建议可以使用普通的旧重定向来更干净地完成此操作。除非您确实需要它,否则不要将 mod_rewrite 的瑞士军电锯拖到游戏中。例如:

Redirect permanent /component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate http://landed.at/itworked

You have included a full path including slashes, but you are only testing it against the HTTP_HOST which will be just landed.at. Did you mean to use REQUEST_URI? (That would have to include the http:// 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:

Redirect permanent /component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate http://landed.at/itworked
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文