Welcome! Log In Create A New Profile

Advanced

regex rewrite problem

January 18, 2012 05:02PM
Hello,

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 example.com/manufacturers/metlox/0?page=13 and change it to example.com/manufacturers/m It seems like the curly braces aren’t working.

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.
Subject Author Posted

regex rewrite problem

mpratt January 18, 2012 05:02PM

Re: regex rewrite problem

Alexander Kolesen January 18, 2012 05:34PM

Re: regex rewrite problem

mpratt January 18, 2012 07:31PM

Re: regex rewrite problem

António P. P. Almeida January 18, 2012 08:50PM

Re: regex rewrite problem

mpratt January 18, 2012 10:46PM

Re: regex rewrite problem

Edho Arief January 18, 2012 10:56PM

Re: regex rewrite problem

mpratt January 19, 2012 08:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 183
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready