问题
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
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!
回答1:
Try:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^page/?$ http://domain.com/page/?Campaign_ID=1234656 [L,NE,R=301]
回答2:
Give this a try:
RewriteCond %{REQUEST_URI} ^(/page/)(.*)$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1?Campaign_ID=1234656 [L,R=301]
来源:https://stackoverflow.com/questions/24151901/use-htaccess-to-append-a-query-string-to-url