2011年3月11日星期五

Re: Having trouble with the PCRE syntax

On Mar 11, 2011, at 20:33 , Maxim Dounin wrote:

> Correct regexp-based solution would be
>
> location ~* ^/(?:forum|forums|board)(?:/|$) {
> rewrite ^/[^/]*/*(.*) http://forum.my_domain.com/$2 permanent;
> }
>
> But recommended way is to avoid regexp-based solutions without
> real need. It's much simplier and much more scalable to write
> configuration with normal static locations, i.e.
>
> location = /forum {
> rewrite ^ http://forum.my_domain.com/ permanent;
> }
> location /forum/ {
> rewrite ^/forum/(.*) http://forum.my_domain.com/$1 permanent;
> }
> location = /board {
> rewrite ^ http://forum.my_domain.com/ permanent;
> }
> location /board/ {
> rewrite ^/board/(.*) http://forum.my_domain.com/$1 permanent;
> }
>
> This way you'll save yourself a headache.

[ when configuration will eventually grow.
And it will certainly grow eventually. ]

> As a side effect - it's
> faster.
>
> Maxim Dounin


--
Igor Sysoev
http://sysoev.ru/en/


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

没有评论:

发表评论