开发者

How can I forward a query string using htaccess?

开发者 https://www.devze.com 2023-01-02 23:31 出处:网络
I am using this, at present, to rewrite URLS: RewriteEngine on RewriteRule ^([^/?\\.]+)$ /page.php?name=$1 [NC]

I am using this, at present, to rewrite URLS:

RewriteEngine on
RewriteRule ^([^/?\.]+)$ /page.php?name=$1 [NC]

So mysite.com/home gets rewritten to mysite.com/page.php?name=home

How can I make it also rewrite mysite.com/home?param=value to mys开发者_StackOverflowite.com/page.php?name=home&param=value? Ideally, I'd like this to work for any name/value querystring pairs.

Am I missing something obvious?


Check out the "capturing variables" section at http://corz.org/serv/tricks/htaccess2.php

It says that if you add [QSA] to the end of the rewrite rule, it should pass variables through the rewrite.


This made it work:

RewriteEngine on
RewriteRule ^([^/?\.]+)$ /page.php?name=$1&%{QUERY_STRING} [NC]
0

精彩评论

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