Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

negate a regular expression

Status
Not open for further replies.

mlmll

Technical User
Joined
Dec 14, 2000
Messages
15
Location
FR
Hi all,

(Q1) I'd like to know if it's possible to negate a regular expression in general, and in htaccess files in particular, and if so, what's the operator ?

For instance, I'd like to negate the regexp

[tt]
^Mozilla
[/tt]

...so in human language, the criteria gives "does not start by 'Mozilla'"

(Q2) Also, do we have logical operators at hand within htaccess files ?

Browsed the docs/newsgroups/web and couldn't find any answer (I'm afraid answer to Q2 is no, but c'mon, there must be solutions for Q1 ! ;-) )

Thanks a lot for any hint.
 
Thanks ifincham for your hints.

I think I finally found a way to achieve what I want without having to negate any regular expression through this :

[tt]SetEnvIfNoCase Referer ^$ allowed_referer
SetEnvIfNoCase Referer ^ allowed_referer
SetEnvIfNoCase Referer ^ allowed_referer

#straps and belt
SetEnvIfNoCase Referer voila\.fr forbidden_referer
SetEnvIfNoCase Referer voila\.com forbidden_referer

#block spiders
BrowserMatch ^Mozilla allowed_agent
BrowserMatch ^Opera allowed_agent
#and for "Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) TrueRobot; 1.4" (voila), squash 'em
BrowserMatch TrueRobot forbidden_agent
BrowserMatch Echo2 forbidden_agent


Order Allow,Deny
Allow from env=allowed_referer
Allow from env=allowed_agent
Deny from env=forbidden_agent
Deny from env=forbidden_referer[/tt]

Though, when I come to my.site.com through a link from google.com, access is allowed !! How come ?

Cheers,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top