在htaccess中添加GET参数 [英] Add GET parameter in htaccess
本文介绍了在htaccess中添加GET参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种向htaccess添加规则的方法,该规则将为在子域中出现的请求自动添加GET参数(原因很长,看起来似乎无关紧要).
I am looking for a way to add a rule to the htaccess that will automatically add a GET parameter to a request coming in on a subdomain (the reason why is a long story and seems irrelevant).
所以sub.example.com应该重定向到sub.example.com?parameter=test
So sub.example.com should redirect to sub.example.com?parameter=test
我遇到的问题是循环引用.必须有避免这种情况的方法吗?
The problem I'm having is the circular reference. There must be a way to avoid this?
推荐答案
您可以尝试以下代码:
RewriteEngine On
RewriteCond %{QUERY_STRING} !(^|&)parameter=test(&|$) [NC]
RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC]
RewriteRule ^ %{REQUEST_URI}?parameter=test [L,R=301,QSA]
这篇关于在htaccess中添加GET参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文