具有参数的URL的RewriteCond [英] RewriteCond for url with parameters
本文介绍了具有参数的URL的RewriteCond的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在重写网址时遇到了问题. 我想要这个:
I've got a problem to rewrite an url. I want this :
http://www.foo.com/test.php?u=s1&id=12345&img=12
到
http://app.foo.com/12345-s1-12.test
第一个参数u是一个字符串,参数id和img是整数.
First parameter u is a string, parameters id and img are integers.
我从这样的东西开始:
RewriteCond %{REQUEST_URI} ^/test.php?u=(.*)&id=(.*)&img=(.*)/ [NC]
RewriteRule (.*) http://app.foo.com/%2-%1-%3.test [QSA,R=301,L]
谢谢:)
仍然无法正常工作,但是我已经接近了!
Still doesn't work but i'm close!
RewriteCond %{REQUEST_URI} ^/test.php [NC]
RewriteCond %{QUERY_STRING} ^u=(.*)&id=(.*)&img=(.*)
RewriteRule (.*) http://app.foo.com/%2-%1-%3.test [QSA,R=301,L]
现在,它给了我该链接:
Now it give me that link :
http://app.foo.com/12345-s1-12.test?u=s1&id=12345&img=12
而不是:
http://app.foo.com/12345-s1-12.test
:(
推荐答案
已解决!
RewriteCond %{REQUEST_URI} ^/test.php [NC]
RewriteCond %{QUERY_STRING} ^u=(.*)&id=(.*)&img=(.*)
RewriteRule (.*) http://app.foo.com/%2-%1-%3.test? [R=301,L]
在RewriteRule的末尾放置?
会删除以前的查询字符串信息.
Placing a ?
on the end of the RewriteRule removes previous query string information.
这篇关于具有参数的URL的RewriteCond的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文