Forum Moderators: phranque
I'm attempting to redirect a page location to the same page location + some URL parameters. Specifically:
^/catalog/hgindex.html should be redirected to
^/catalog/hgindex.html?ct=hg
When I attempt to add the rewrite rule to httpd.conf, I get an endless loop of the page trying to load. I've tried different incantations of the rewrite rule, but I'm missing something. WOuld someone graciously lend a hand?
Thank you.
Alisa
Welcome to WebmasterWorld [webmasterworld.com]!
You'll need to use a RewriteCond directive ahead of your RewriteRule to test the query string to make sure it is blank before you rewrite it. Otherwise, your server may loop as you describe.
The general form would be:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/catalog/hgindex\.html$ /catalog/hgindex.html?ct=hg [L]
Jim
This works:
RewriteCond %{QUERY_STRING} ^$
RewriteRule /catalog/hgindex.html$ /catalog/hgindex.html?ct=hg [L,R]
But I had to place it before another very specific set of rewrite rules in the httpd.conf file, so that this rule would be executed first - I originally had the rule at the end of the file, and the other rewrite rule that is in place was overriding it.
Thanks again for all your help. And thank you for your time and assistance. I see that you get a LOT of traffic here and that you personally respond to each post. That's a lot of effort. Thanks for your direction. It was enough for me to figure it out the rest on my own.
Alisa
Jim