0

Is there any way to redirect this link :

http://example.com/?page=profile.php&id=100

to

http://example.com/profile.php?id=100

using htaccess ?? by the way I know that I can redirect from

http://example.com/?page=profile.php

to:

http://example.com/profile.php

using 301 redirect

but I am asking about the id in the first link I use it with & while in the second URL I use it with ? is there a way to make the redirect taking the id parameter in consideration

1 Answer 1

1

Try this :

RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=([^&]+)&id=([^&]+) [NC] 
RewriteRule ^ /%1?id=%2 [NC,R,L]
Sign up to request clarification or add additional context in comments.

2 Comments

actually when I add this to the .htaccess file and call the old URL I was redirected to somewhere like this http://example.com/home/account_name/public_html/example.com/profile.php?id=100 so as you can see it is redirected and the ?page and ? sign are changed but the problem is in the path . it gives me a new path ?? why does it do that?
Thank you so much now it is working very good , but I want your recommendation about something , if the URL does not have an id parameter just like this ?page=profile.php and I want to make it 'profile.php' if I add 301 redirect could that contrast with the code you gave me?

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.