Bryan Wong
Bryan Wong

Reputation: 633

HTACCESS Don't Redirect With Parameters

I got this line of code:

RewriteRule artistprofile.php rewrite.php?$1 [R=301,L]

But the redirection does not work accordingly,

http://domain.com/artistprofile.php?displayname=bryan+wong is redirected to http://domain.com/rewrite.php?/

I am expecting http://domain.com?displayname=bryan+wong

Please help!

Upvotes: 0

Views: 46

Answers (2)

piouPiouM
piouPiouM

Reputation: 5037

You have to use the QSA flag, like this:

RewriteRule artistprofile.php rewrite.php [R=301,L,QSA]

Now, the URL http://domain.com/artistprofile.php?displayname=bryan+wong will be redirected to http://domain.com/rewrite.php?displayname=bryan+wong.

Upvotes: 2

Nawwar Elnarsh
Nawwar Elnarsh

Reputation: 1069

You didn't catch the query first to use $1 try this

RedirectMatch /artistprofile.php?displayname=(.*)$ rewrite.php?displayname=$1

Upvotes: 0

Related Questions