简体   繁体   中英

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!

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 .

您没有先使用$ 1捕获查询,请尝试

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM