Rewrite n00b

Hi,
Just wanting to enabled a rewrite of the following url,

Redirecting all requests from http://www.domain.com/site/forums and
http://www.domain.com/forums to http://forums.domain.com

Thanks :slight_smile:

On Thu, May 12, 2011 at 02:13:03PM +1200, Ryan B wrote:

Hi,
Just wanting to enabled a rewrite of the following url,

Redirecting all requests from http://www.domain.com/site/forums and
http://www.domain.com/forums to http://forums.domain.com

server {
server_name www.domain.com;

location /forums {
    rewrite  ^/forums(.*)$  http://forums.domain.com$1;
}

location /site/forums {
    rewrite  ^/site/forums(.*)$  http://forums.domain.com$1;
}

...

–
Igor S.

Awesome thanks :slight_smile:

I’ve got this, to redirect the requests, but If I request a file from
the orginal host, it won’t redirect to the same file on the ip.

rewrite ^ http://113.214.191.192 permanent;

So http://domain.com/files.txt → redirects to
http://113.214.191.192/files.txt (without the need to specifiy each
file name)

Thanks for the help

On Sat, May 14, 2011 at 03:02:52AM +1200, Ryan B wrote:

Awesome thanks :slight_smile:

I’ve got this, to redirect the requests, but If I request a file from
the orginal host, it won’t redirect to the same file on the ip.

rewrite ^ http://113.214.191.192 permanent;

So http://domain.com/files.txt → redirects to
http://113.214.191.192/files.txt (without the need to specifiy each
file name)

rewrite ^ http://113.214.191.192$request_uri? permanent;

–
Igor S.