开发者

How to get values from query string and pass it to new page using .htaccess file

currently I m using following code in my site in .htaccess file :

RewriteRul开发者_如何学Pythone ^([^/\.]+).php?$ comman.php?cat=$1 [L]

This redirects user to comman.php page say, user requests

http://www.mysite.com/myfolder/page1.php

will redirects to

http://www.mysite.com/myfolder/comman.php?cat=page1

This works fine. My question is how can I achieve following

http://www.mysite.com/myfolder/page1.php?var1=123

to redirect

http://www.mysite.com/myfolder/comman.php?cat=page1&param=123

i.e. whatever value passed to url using get method to add in my new url.

Thanks in Advance.....


You should add the QSA flag:

RewriteRule ^([^/\.]+).php?$ comman.php?cat=$1 [L,QSA]

QSA stands for Query String Append. Anything after the ? in the original URL will be appended to the rewritten URL.


You need to ass QSA to your rule, i.e.

RewriteRule ^(.*)$ /index.php?pageid=$1 [QSA,L]


You can use the QSA flag in your RewriteRule for that.

See the docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜