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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.