Mod_rewrite - Don't get second rule work

I want to have a URL like this: domain.com/css/site.css?test=234

Rule:

RewriteEngine On
RewriteRule ^([a-z]+)/$ $1.php
RewriteRule ^css/([a-zA-Z0-9]+).css?count=(.*)$ css.php?f=$1&test=$2

      

But I get every time 404: Not Found (site.css)

If I have a rule like this, it works by simply not getting the $ _GET-Variable:

RewriteEngine On
RewriteRule ^([a-z]+)/$ $1.php
RewriteRule ^css/([a-zA-Z0-9]+).css$ css.php?f=$1

      

+2


a source to share


1 answer


The request string is missing from the url to match the RewriteRule. You need something like this:

RewriteEngine On
RewriteRule ^([a-z]+)/$ $1.php

RewriteCond %{QUERY_STRING} count=(.*)$
RewriteRule ^css/([a-zA-Z0-9]+).css$ css.php?f=$1&test=%1

      



You can read more about RewriteCond

and RewriteRule

here http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond

You can see the order of execution of RewriteConds and RewriteRules here http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#InternalRuleset

+2


a source







All Articles