PHP not working in regex locations (?)

Jonathan Vanasco nginx at
Thu Apr 23 21:54:02 MSD 2009

I figured out the problem, and a temporary solution

looking through my mailbox i saw this thread:

	From: 	lists at
	Subject: 	php and locations with regex (round 2)
	Date: 	October 23, 2007 6:44:21 AM EDT
which was the same issue as me.

the problem is that my macro for php is the very standard block

	location ~ *.php {}

which should not have been used within a static or regex location -  
only in a server
but there is a behavior where it does work on static location

so i created a temporary fix: i made another macro which was just the  
contents of the php block

in the 2007 thread, igor said that it would be bad to use an if ()  
match on files... is this still true?

ideally i would like to do this:

location ~ /regex/ {
	if ( filename *~ *.php(\?.*)? ) {
		fcgi passover
	handle static stuff here

More information about the nginx mailing list