Skip to content
Advertisement

Add New Parameter to Existing URL using htaccess

I have a url like below

http://filespecification.phpnet.us/index3.php

But i want to add an additional parameter to this url like below.

http://filespecification.phpnet.us/index3.php?email=

For this i am using .htaccess to redirect with additional parameter but it is not redirecting still show original url.

RewriteRule /index3.php$ index3.php?email=$1 [R]

But it is not working. How can i redirect with additional parameter?

Advertisement

Answer

Try this simple one. Hope this will be helpful. I have tested it.

1. QUERY_STRING does not contain email.

2. if request uri is index3.php redirect to /index3.php?email=somevalue

Flags:

R for redirection.

L last redirection.

QSA query string append

RewriteEngine on
RewriteCond %{QUERY_STRING} ^(?!email)
RewriteRule index3.php$ /index3.php?email=somevalue [L,R,QSA]

You can check this .htaccess code here http://htaccess.mwl.be/

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement