开发者

Use mod_rewrite, yet keeping the "?"

开发者 https://www.devze.com 2023-02-12 08:53 出处:网络
I\'m wasting hours here with .htaccess to make those nice looking URLs possible and reached a dead end. This is what worked for me in the past:

I'm wasting hours here with .htaccess to make those nice looking URLs possible and reached a dead end. This is what worked for me in the past:

RewriteRule ^(.*)\?*$ app.php?_target=$1 [L]

Now I would like to extend this rule to support URLs like this:

http://mydomain.com/articles/regex-cheatsheet/?sortby=expression&order=asc&filter=numeric

Here is a nice explanation for why I would like doing this. My rule looks like this now:

RewriteRule ^(.*)\?(.*)$ app.php?_target=$1&$2 [L]

I've validated this expression, as I am no regEx expert and it seems OK. Bu开发者_开发百科t, of course, it doesn't work :/

So does anyone know what I am doing wrong?


Use the QSA (Query String Append) flag:

RewriteRule (.*) app.php?_target=$1 [L,QSA]
0

精彩评论

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