Search code examples
apache.htaccessmod-rewriteurl-rewritingpermalinks

URL rewrite in htaccess


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.


Solution

  • 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