Mod Rewrite - Variables after conditions

Mod Rewrite - Variables after conditions

am 16.10.2007 21:51:44 von Adam

I have a few conditions written in my .htaccess which all work fine,
but my problem is I want to use variables after the rewritten
conditions. I have conditions written similar to the following, but
how can I get it to take into account anything after the condition?


..htaccess ----

Options +FollowSymlinks
RewriteEngine On

RewriteRule ^(cp|forum|etc)/?$ index.php?module=$1 [L]


This rewrites http://mysite.com/cp/ to http://mysite.com/index.php?module=cp
but for AJAX purposes I would like to rewrite the following:

http://mysite.com/cp/?ajax=true --> http://mysite.com/index.php?module=cp&ajax=true

I have a few more purposes for this so it would be useful to set a
general rule.

Thanks in advance

Re: Mod Rewrite - Variables after conditions

am 16.10.2007 22:01:12 von Jim Hayter

adam@areasix.co.uk wrote:
> I have a few conditions written in my .htaccess which all work fine,
> but my problem is I want to use variables after the rewritten
> conditions. I have conditions written similar to the following, but
> how can I get it to take into account anything after the condition?
>
>
> ..htaccess ----
>
> Options +FollowSymlinks
> RewriteEngine On
>
> RewriteRule ^(cp|forum|etc)/?$ index.php?module=$1 [L]
>
>
> This rewrites http://mysite.com/cp/ to http://mysite.com/index.php?module=cp
> but for AJAX purposes I would like to rewrite the following:
>
> http://mysite.com/cp/?ajax=true --> http://mysite.com/index.php?module=cp&ajax=true
>
> I have a few more purposes for this so it would be useful to set a
> general rule.
>
> Thanks in advance
>

To keep the original query string, you just to add the "QSA" flag to
your rule (e.g., [L] becomes [QSA,L]).

Jim