开发者

How to redirect all requests to index.php and keep the other GET params?

Here's what I've got so far:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule .* index.php?url=$0 [L]
开发者_运维问答

But when I go to soemthing like /a?b=c and then inspect the GET params, I only get a for url, and b is lost. How can I retain that?


How about using the FallbackResource directive: "Define a default URL for requests that don't map to a file"

<Directory /web/example.com/htdocs/blog>
    FallbackResource /index.php
</Directory>

That way you don't have to call the modRewrite module on every request.

http://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource


RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule .* index.php?url=$0 [QSA,L]

You need the QSA in your rewrite rule.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜