Regex rewrite to root document

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?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,221278,221278#msg-221278

On 16 Jan 2012 04h35 WET, [email protected] 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

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 ~ ^/(?.+)$ {
fastcgi_pass …
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path/to/post/php;
fastcgi_param QUERY_STRING id=$id;
}


Igor S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs