简体   繁体   English

根据网址匹配进行重定向

[英]redirect based on url match

I can't get a certain URL to redirect using mod rewrite. 我无法使用mod rewrite获得某个URL进行重定向。 I am getting more basic rewriting happening so this is functioning as far as that goes so there is a problem with my URL. 我正在进行更多的基本重写,因此该功能可以正常运行,因此我的URL有问题。

I tried the string here and it showed the patter works.. 我在这里尝试过该字符串,它显示出p沥的作品。

http://regexpal.com/ 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 实际上,我想提取一下standard:5和jr_country:sri-lanka来创建变量,以便我的网址变为

http://landed.at/tours/sri-lanka - tours if criteria:5 and sri-lanka from the jr_country http://landed.at/tours/sri-lanka-符合条件的游览:jr_country中的5和sri-lanka

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? 根据正则表达式,它应该找到条件并进行重写?

You have included a full path including slashes, but you are only testing it against the HTTP_HOST which will be just landed.at . 您已经包含了包括斜杠在内的完整路径,但是您仅针对将要landed.atHTTP_HOST进行了landed.at Did you mean to use REQUEST_URI ? 您是要使用REQUEST_URI吗? (That would have to include the http:// also.) (这还必须包括http:// 。)

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. 在真正需要它之前,请勿将mod_rewrite的瑞士军用电锯拖入游戏。 eg: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM