1

Let me start by saying I am not an .htaccess or Apache expert by any means. But I have the need to append a hashed term to the end of a URL query.

For example:

http://www.example.com/?query_string=stuff

becomes

http://www.example.com/?query_string=stuff#otherstuff

I am using the following rule (entire .htaccess file):

RewriteCond %{QUERY_STRING} ppw_confirm=(.*)
RewriteRule ^/?(.*) http://www.example.com/?ppw_confirm=%1#go [NE,L]

THE PROBLEM

After adding #go to the end of the parameter string, the .htaccess file still reads the ?ppw_confirm= query. It then attempts to perform a second redirect after which an infinite loop ensues.

I've been searching around for hours with no luck. Basically, I need a way to prevent .htaccess from re-writing twice to thus prevent this endless loop.

Open to any and all suggestions :)

Any help is greatly appreciated. Thanks in advance!

  • Are you looking to send an HTTP 30x response to the client to add the #go? – Shane Madden Jun 20 '13 at 0:59
  • Boy, I wish I knew what that meant :) Basically, I am redirecting an incoming query parameter and then adding the code#go. Just stuck in the endless loop issue. – Brian Jun 20 '13 at 1:55
  • Is the client browser getting the #go added to its address bar? – Shane Madden Jun 20 '13 at 2:35
  • Ah, yes, the #go is being added to the URL bar at the end of the entire parameter, which looks something like this: http://www.example.com/?ppw_confirm=1&token=EC-1MV99112AX383650S&PayerID=PQN8BZYCRGYUY#go – Brian Jun 20 '13 at 3:44
0

The #go part isn't something you can work with in rewrite rules at all; it's client-side, not sent to the server when making a request for that resource, so you're not able to make decisions in rules based on it.

Maybe as part of the redirect, add an additional variable to the query string, then look for that variable and prevent the redirect when it's present?

RewriteCond %{QUERY_STRING} ppw_confirm=(.*)
RewriteCond %{QUERY_STRING} !r=1
RewriteRule ^/?(.*) http://www.example.com/?ppw_confirm=%1&r=1#go [NE,L]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.