0

How can I redirect http://www.mywebsite.com/confirm-registration/?registration_date=1405281684&email_address=email@googlemail.com to http://www.mywebsite.com/blog/confirm-registration/?registration_date=1405281684&email_address=email@googlemail.com through htccess ?

*registration_date and email_address values will be dynamic in the URL.

I have tried...

RewriteRule http://www.mywebsite.com/confirm-registration/?registration_date=^([a-zA-Z0-9])\$&email_address=^([a-zA-Z0-9])\$ http://www.mywebsite.com/confirm-registration/?registration_date=$1&email_address=$2 [QSA,NC,L]

Thanks in advance,

~ Dipak G.

anubhava
  • 761,203
  • 64
  • 569
  • 643
Dipak G.
  • 715
  • 1
  • 4
  • 18

1 Answers1

0

RewriteRule is only used for matching REQUEST_URI and that doesn't include protocol, domain name or query string.

You can use this rule in root .htaccess:

RedirectMatch 301 ^/confirm-registration/ /blog/confirm-registration
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I have tried your answer but when I open http://www.mywebsite.com/confirm-registration/?registration_date=1405281684&email_address=email@googlemail.com in the browser, it's not redirecting to http://www.mywebsite.com/blog/confirm-registration/?registration_date=1405281684&email_address=email@googlemail.com ? – Dipak G. Jul 15 '14 at 19:27
  • Comment out `RewriteCond` line and retest. – anubhava Jul 15 '14 at 19:33
  • Add a line here: `RedirectMatch foo /bar` and then open `http://example.com/foo` to see if you get `http://example.com/bar` or not – anubhava Jul 15 '14 at 19:38
  • Ok try: `RedirectMatch /confirm-registration/ /blog/confirm-registration` rule – anubhava Jul 15 '14 at 19:58
  • This redirects but getting 'This webpage has a redirect loop' - why? – Dipak G. Jul 15 '14 at 20:06
  • Try this instead: `RedirectMatch ^/confirm-registration/ /blog/confirm-registration` – anubhava Jul 15 '14 at 20:18
  • Finally `RedirectMatch ^/confirm-registration/ /blog/confirm-registration` did the trick. Thank you. – Dipak G. Jul 16 '14 at 02:57