'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?
Solution 1:[1]
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/
Solution 2:[2]
Your rule isn't working due to the leading slash. You need to remove it.
RewriteCond %{THE_REQUEST} !\?email= [NC]
RewriteRule index3.php$ /index3.php?email=mail [L,R]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |
Solution 2 |