How to redirect user from www.myhostname.com to hostname.com

how to redirect user from http://www.myhostname.com to
http://hostname.com ??
i mean if they access http://www.myhostname.com he will be redirected to
http://hostname.com
pls help me

Posted at Nginx Forum:

Hello!

On Mon, Apr 19, 2010 at 10:11:13PM -0400, escavern wrote:

how to redirect user from http://www.myhostname.com to http://hostname.com ??
i mean if they access http://www.myhostname.com he will be redirected to http://hostname.com
pls help me

server {
listen 80;
server_name www.myhostname.com;

rewrite ^ http://hostname.com$request_uri? permanent;

}

Maxim D.

On 4/19/10 10:11 PM, escavern wrote:

how to redirect user from http://www.myhostname.com to http://hostname.com ??
i mean if they access http://www.myhostname.com he will be redirected to http://hostname.com
pls help me

server {
listen 80;
server_name hostname.com;

}

server (
listen 80;
server_name www.myhostname.com;
rewrite ^ http://hostname.com$request_uri? permanent;
}

This assumes you want a redirect to the requested URI. If you want all
requests to go to the index page for http://hostname.com omit
“$request_uri?” from the rewrite.

Posted at Nginx Forum: how to redirect user from www.myhostname.com to hostname.com


nginx mailing list
[email protected]
nginx Info Page


Jim O.