Regex rewrite to root document

Igor Sysoev igor at sysoev.ru
Mon Jan 16 09:58:18 UTC 2012


On Sun, Jan 15, 2012 at 11:35:44PM -0500, etrader 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="

location = / {
    ...
}

location ~ ^/(?<ID>.+)$ {
    fastcgi_pass   ...
    include        fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  /path/to/post/php;
    fastcgi_param  QUERY_STRING     id=$id;
}


-- 
Igor Sysoev



More information about the nginx mailing list