.htaccess redirect from url to url with param

2019-09-02 14:28发布

I'm trying to redirect from an url to an url with parameters: from http://www.domain.com/dir1/dir2/dir3/paramid to http://www.domain.com/dir4/dir5?search=param1&task=search&id=paramid

I tried in .htaccess the following :

RewriteRule ^dir1/dir2/dir3/(.*)$ /dir4/dir5?search=param1&task=search&id=$1 [R=301,L]

But I can't get it to work.

Help appreciated.

1条回答
The star\"
2楼-- · 2019-09-02 14:58

I believe you might be looking for the QSA or Query String Append Command Flag Block.

RewriteRule /dir1/dir2/dir3/(.+) /dir4/dir5?page=$1 [QSA]

Your solution is fine, as far as syntax goes, but there may be some lower-level functionality you're missing by bypassing the QSA command flag.

查看更多
登录 后发表回答