How to catch a request that has a given word in url?

Igor Sysoev igor at sysoev.ru
Mon Aug 9 13:20:20 MSD 2010


On Mon, Aug 09, 2010 at 11:16:53AM +0200, Fernando Perez wrote:

> Hi,
> 
> I am trying to catch any request that has WORD in the url, eg:
> 
> catch: http://example.org/whatever/path/WORD/file.pdf
> 
> don't catch: http://example.org/some/other/path/anotherfile.jpg
> 
> and if simple to do, don't catch: http://example.org/folder/WORD.doc
> 
> 
> I tried:
> 
> location ^~ /WORD/ {}
> 
> location WORD {}
> 
> location ~* WORD {}
> 
> 
> But none seemed to do want I want*.
> 
> Thanks for your advice :)

Place

   location ~ /WORD/ {
       ...
   }

as the first location in a server.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list