htaccess condition

Hi,

My .htaccess file has the following content:

---------------------------
SetEnv PHP_VER 5
RewriteEngine on
RewriteCond %{REQUEST_URI} !/img.*
RewriteCond %{REQUEST_URI} !/admin.*
RewriteBase /
RewriteCond %{REQUEST_URI} !/javascript.*
RewriteRule !\.(js|ico|gif|jpg|png|css|swf)$ index.php
---------------------------

So all the requests are forwarded to index.php
But I want to add a rule:
if there is a request to googlehostedservice.html or to info.php,
I do not want to forward to index.php
Also if someone can explain me the RewriteCond instructions.

Thank you.
LVL 9
matthew016Asked:
Who is Participating?
 
Steve BinkConnect With a Mentor Commented:
You can see all the information on mod_rewrite here:

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

The rewrite rules and conditions are based in regular expressions.  For example, !\.(js|ico|gif|jpg|png|css|swf)$:

! = not operator.  Means the condition will be true if the expression is NOT matched.
\. = an actual period character.  The slash is called an escape character, and is used to indicate that the next character should be interpreted literally.  Normally, regex sees a period as a marker for 'any character'
$ = end of line marker.  This is generally used to indicate an EOL character (\n or \r\n), though I believe it means end-of-input in this context.
(js|ico|gif|jpg|png|css|swf) = indicates several alternatives that should be accepted as a match.  This is a parenthetical list, delimited by pipe (|) characters.

Combining all of those together:

If the request URI being submitted does NOT include a period, followed by js or ico or gif or jpg or png or css or swf, followed immediately by the end of input, then this condition applies.

You can find more information about how to build regular expressions here:

http://www.regular-expressions.info/tutorialcnt.html

For your new rule, try adding the following lines:


RewriteCond %{REQUEST_URI}	!googlehostedservice.html [NC]
RewriteCond %{REQUEST_URI}	!info.php [NC]

Open in new window

0
 
matthew016Author Commented:
Thank you,

what is [NC] for ?
it seems to work without
0
 
Steve BinkCommented:
[NC] is a modifier indicating no case sensitivity is to be used for the comparison.  Without the [NC] modifier, info.php would violate the condition, where INFO.php would match it.
0
All Courses

From novice to tech pro — start learning today.