.htaccess two different rules but only one per time

Posted by dragon112 on Pro Webmasters See other posts from Pro Webmasters or by dragon112
Published on 2012-09-12T08:56:09Z Indexed on 2012/09/12 9:49 UTC
Read the original article Hit count: 144

Filed under:
|

I'm rather new to the whole .htaccess thing and I'm using the following right now to use 'pretty url's':

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?path=$1 [NS,L]
</IfModule>

Now i found my website a bit slow and decided to start gzipping my CSS files thru a php script I found somewhere on the web (the website). For this to work I need to rewrite the url to open the correct php file. That would look something like this:

RewriteRule ^(.*).css$ /csszip.php?file=$1.css [L]

But I only want the first to happen when the second doesn't and vice versa. In other words i'd like something like this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    if request doesn't contain .css do
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?path=$1 [NS,L]
    else do
        RewriteRule ^(.*).css$ /csszip.php?file=$1.css [L]
</IfModule>

Can anyone help me with the proper code or a place where i can find a way to use some kind of conditional statement in htaccess files?

Thanks in Advance!:)

© Pro Webmasters or respective owner

Related posts about htaccess

Related posts about mod-rewrite