Re: Regex help

From: Date: Wed, 22 Aug 2001 13:56:18 +0000
Subject: Re: Regex help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63901@lists.php.net to get a copy of this message
stefenlars@hotmail.com (Stefen Lars) writes: > In the Apache config file, we have the following directive: > > SetEnvIfNoCase Referer "^http://www.oursite.com/" > local_ref=1 > > <FilesMatch ".(gif|jpg)"> > Order Allow,Deny > Allow from env=local_ref > </FilesMatch> > > We use this to prevent people from directly linking to .gif and .jpg > files. > > However, we have to add more and more file types to the FilesMatch > directive. Currently it looks like this: > > <FilesMatch ".(doc|zip|xls|exe|jpg|gif|png|psd|tif|tif)"> > > However, this list continues to grow. And we can never be sure that > every file type is included. > > It occurred to me that it would be better to say "do not serve any > files except .htm, .html and .php files.". > > > I have spent quite a long time with several regexes, but I am unable > to create a regex that archives this seemingly simple talk. > How about this approach? SetEnvIfNoCase Referer "^http://www.oursite.com/" local_ref=1 Order Allow,Deny Allow from env=local_ref <FilesMatch "\.(php|html?)$"> Allow from all </FilesMatch> I'd tighten up your regex slightly too. As it was it would match pretty much any filename with those letters in it; The '.' matches any character and it's not anchored to the end of the string. -robin

« previous php.general (#63901) next »