简体   繁体   English

奇怪的URL重写行为

[英]Strange url rewriting behavior

I have to redirect all my urls like that: 我必须像这样重定向所有网址:

http://www.domain.ltd/foo/bar/var1/var2/var3.html 
to
http://www.other.ltd/search?q=var3&long=0

I tried the following: 我尝试了以下方法:

RedirectMatch 302 ^foo/bar/(.+)/(.+)/(.+)\.html$ http://www.other.ltd/search?q=$3&long=0

It seems to work but I have the last url still sticking to the end of my var3 variable : 看来可行,但是我的最后一个URL仍然贴在var3变量的末尾:

http://www.other.ltd/search?q=var3/foo/bar/var1/var2/var3.htmllong=0

Any clue? 有什么线索吗?

Use mod_rewrite rule for stripping original query string. 使用mod_rewrite规则剥离原始查询字符串。

Put this code in your DOCUMENT_ROOT/.htaccess file: 将此代码放在您的DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On
RewriteBase /

RewriteRule ^foo/bar/([^/]+)/([^/]+)/([^.]+)\.html$ /search?q=$3&long=0 [R=301,L,NE]

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

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