1

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?

6
  • What is the value of email you are expecting? Commented Jun 21, 2017 at 6:32
  • $1 is not defined Commented Jun 21, 2017 at 6:33
  • Remove the leading slash from your Rule's pattern. Commented Jun 21, 2017 at 6:33
  • any value can be added to this by writing manually in url. Commented Jun 21, 2017 at 6:33
  • @starkeen when change the rule to this RewriteRule index3.php$ index3.php?email=$1 [R] then it redirect to this url. http://filespecification.phpnet.us/here is it shows complete patha like Public_html /index3.php?page= Commented Jun 21, 2017 at 6:36

2 Answers 2

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/

Sign up to request clarification or add additional context in comments.

6 Comments

it works, can you please explain, what is function of first line? RewriteCond %{QUERY_STRING} ^$
nicely understand you, but now i change my your rule to this RewriteRule .*$ /index.php?email= [L,R] means when someone visit http://filespecification.phpnet.us it redirects to http://filespecification.phpnet.us/index.php?email= but all images are not showing.
I got the issue, on your website you have img/Offices.png which is the link of your image, i cant be accessed because you have redirected all requests to index.php
@HamzaZafeer You will get to know the issue, if you try to open this link filespecification.phpnet.us/img/Offices.png Can you explain in brief what you are trying to do.
got it, how can i overcome this? This solution give me a new problem.
|
0

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]

2 Comments

it redirects, but browser says This page isn’t working filespecification.phpnet.us redirected you too many times.
Sorry, i forgot to add the condition to check empty querystring. Fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.