Regex rewrite to root document

António P. P. Almeida appa at perusio.net
Mon Jan 16 04:59:03 UTC 2012


On 16 Jan 2012 04h35 WET, nginx-forum at nginx.us wrote:

> I have a simple re-write of
>
> rewrite ^/(.*) /post.php?id=$1 last;
>
> This will breaks my main index page, as domain.com will also be
> redirected to "post.php?id="
>
> How can I modify my regular expression not to change the main index
> page?

Easier to define *another* location without any rewrite just for / :

location = / {
    ...
}

location / {
    # do the rewrite here
    ...
}

--- appa



More information about the nginx mailing list