htaccess的重定向与查询字符串 [英] htaccess redirect with query string
问题描述
我已经URL与一个链接参数。我想这重定向到一个PHP文件。 我怎样才能实现这一点使用htaccess的文件吗?
来源网址:www.example.com/?id=15&L=1&link=androidapp </ P>
目标URL:www.example.com/test.php
我要检查,如果链接= androidapp的存在,然后重定向到PHP文件。
我已经试过以下code,但没有工作;
的RewriteCond%{QUERY_STRING} ^链接= androidapp $
重写规则^(。*)$ http://www.example.com/test.php? [R = 301,L]
你们可以请帮我解决这个问题? 谢谢你。
它应该工作,如果你跳过 ^
的 $ $和C $ C>是这样的:
的RewriteCond%{QUERY_STRING}链接= androidapp
重写规则^(。*)$ http://www.example.com/test.php? [R = 301,L]
在 ^
表示您的模式只是从查询字符串的开始比赛,但你的查询字符串以的id = 15 ...
I've url with a link parameter in it. I want redirect this to a php file. How can I implement this using htaccess file?
Source url: www.example.com/?id=15&L=1&link=androidapp
Target url: www.example.com/test.php
I want to check if "link=androidapp" exists, then redirect to the php file.
I've tried the following code, but not working;
RewriteCond %{QUERY_STRING} ^link=androidapp$
RewriteRule ^(.*)$ http://www.example.com/test.php? [R=301,L]
Can you guys please help me to solve the problem? Thanks.
It should work if you skip the ^
and the $
like this:
RewriteCond %{QUERY_STRING} link=androidapp
RewriteRule ^(.*)$ http://www.example.com/test.php? [R=301,L]
The ^
means that the your pattern matches only from the beginning of the querystring, but your querystring begins with id=15...
这篇关于htaccess的重定向与查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!