Rewrite rule and the try_files directive

Captain_Quor nginx-forum at
Fri May 25 12:01:04 UTC 2012

Hi guys,

I'm a little stuck here and wondered if anyone could help, I have a
customer's website with the following rewrite rule:

'rewrite ^/(.*)$ /index.php?town=$1 last;'

This has functioned just fine until they've added three smaller
management sites that they want to be able to reach by appending either
/mms, /admin or /newsletter to the end of the URL (I have tried to steer
them towards subdomains but to no avail!) now these are obviously being
picked up by my rewrite rule and as the website doesn't recognise these
as "towns" it's simply redirecting them back to the home page.

Does anyone know a clean way of achieving this, I was originally looking
at an 'if' statement but I've been warned off this when it comes to
nginx due to the obvious reasons, I've been looking in to the try_files
directive but I'm still a little unsure as to how it actually works.

Any help greatly appreciated.



Posted at Nginx Forum:,226772,226772#msg-226772

More information about the nginx mailing list