nginx rewrite base url

Posted by ptn777 on Server Fault See other posts from Server Fault or by ptn777
Published on 2012-03-24T23:20:37Z Indexed on 2012/03/24 23:31 UTC
Read the original article Hit count: 177

Filed under:
|
|

I would like the root url

http://www.example.com

to redirect to

http://www.example.com/something/else

This is because some weird WP plugin always sets a cookie on the base url, which doesn't let me cache it.

I tried this directive:

location / {
    rewrite  ^  /something/else  break;
}

But 1) there is no redirect and 2) pages start shooting more than 1,000 requests to my server. With this one:

 location / {
        rewrite  ^  http://www.example.com/something/else  break;
    }

Chrome reports a redirect loop.

What's the correct regexp to use?

© Server Fault or respective owner

Related posts about nginx

Related posts about rewrite