regex rewrite problem

mpratt nginx-forum at
Wed Jan 18 22:02:02 UTC 2012


I am new to this forum. Glad it exists. Thanks for that. I have a
production website that uses nginx 0.8.53 reverse proxy in front of
apache. I actually had little problem setting that up, but this simple
regex is giving me a headache.

For some reason, I am unable to take a URI like and change it to   It seems like the curly braces aren’t

I’ve tried the following without results:

location ~* /manufacturers/ {
        rewrite "^/manufacturers/(.{1})/(.*)$"
/manufacturer/directory/$1 redirect;
location ~* /manufacturers/ {
        rewrite "^/manufacturers/([a-z] {1})/(.*)$"
/manufacturer/directory/$1 redirect;

location ~* /manufacturers/ {
        rewrite "^/manufacturers/([a-z]?)/(.*)$"
/manufacturer/directory/$1 redirect;

I am fairly new to regex, so maybe this is something simple. What I want
to get is the first letter of first captured word.  I am able to pull
the entire word with (.*) for $1, but not the first letter only. 

Any help would be greatly appreciated!

Thanks in advance.

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

More information about the nginx mailing list