2011年3月11日星期五

Re: Having trouble with the PCRE syntax

On Fri, Mar 11, 2011 at 10:01:03AM -0500, strike wrote:

Hi there,

> would anybody please tell me what I'm doing wrong here?
>
> location ~* ^/(forum|forums|board)/? {

You ask for /, forum, then one-or-no slash.

> It's working so far, but it also redirects
> visitors from ex. http://www.my_domain.com/forumfoobar/, which isn't
> what I want. :-(

The second "f" in "forumfoobar" is one-or-no slash. (Specifically,
it is no slash). So it matches.

You want to ask for /, forum, then either a slash or end-of-string.

location ~* ^/(forum|forums|board)(/|$) {

(You could also abbreviate forum|forums to forums?, should you so choose.)

Good luck,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

没有评论:

发表评论