使用htaccess的追加查询字符串URL [英] Use htaccess to append a query string to URL

查看:268
本文介绍了使用htaccess的追加查询字符串URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要追加查询字符串为活动跟踪/表单提交某些网址。因此,举例来说,我需要 http://domain.com/page/ 重定向到的 http://domain.com/page/?Campaign_ID=123456

I need to append query strings to certain URLs for campaign tracking/form submission. so for instance, i need http://domain.com/page/ to redirect to http://domain.com/page/?Campaign_ID=123456

我的方式试图将其设置是给我一个重定向循环错误消息,当我试图访问domain.com/page:

The way i tried to set it up is giving me a redirect loop error message when i try to visit domain.com/page:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
Redirect 301 /page http://domain.com/page/?Campaign_ID=1234656

我也试过跟重写规则来代替,这也让我有循环消息:

I also tried it with RewriteRule instead, and that is also giving me the loop message:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^page$ http://domain.com/page/?Campaign_ID=1234656 [L,NE,R=301]

我很抱歉,如果这个问题已经有了答案就在这里。我搜索了一段时间,找不到它,所以请不要骂我的帖子。我也试图找到它在我自己的。谢谢!

i'm sorry if this question has already been answered on here. i searched for awhile and couldn't find it, so please don't yell at me for posting. i did try to find it on my own. thanks!

推荐答案

尝试:

RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^page/?$ http://domain.com/page/?Campaign_ID=1234656 [L,NE,R=301]

这篇关于使用htaccess的追加查询字符串URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆