Redirect 301 alias domain

hi,

i want to do a 301 redirect on all my alias domain for a domain

but i stuck in an infinite loop!

server{
listen 80;
server_name www.aaa.com www.aa.com
return 301 http://www.bbb.com$request_uri;

}

server{
listen 80;
server_name www.bbb.com

}

how to solve this ?

thanks,
bye

Posted at Nginx Forum:

On Mon, Mar 03, 2014 at 10:43:01AM -0500, zuckbin wrote:

Hi there,

i want to do a 301 redirect on all my alias domain for a domain

but i stuck in an infinite loop!

What’s the problem?

What request do you make; what response do you get; what response do you
want?

f

Francis D. [email protected]

i got this error

The page isn’t redirecting properly

in firebug i can see this many times:

GET www.aaa.com 301 Moved Permanently aaa.com

it seem this is not redirect well

Posted at Nginx Forum:

On Tue, Mar 04, 2014 at 06:10:31AM -0500, zuckbin wrote:

Hi there,

in firebug i can see this many times:

GET www.aaa.com 301 Moved Permanently aaa.com

it seem this is not redirect well

This seems to say the when you ask for http://www.aaa.com/, you are
redirected to http://aaa.com/.

The config fragment you provided showed that you should be redirected to
http://www.bbb.com/.

I suspect that the config fragment you provided is not the relevant part
of the configuration file that is actually being used by nginx.

The output of “curl -i http://www.aaa.com/” will probably be useful to
see if your nginx is being used at all.

f

Francis D. [email protected]

Hello!

On Mon, Mar 03, 2014 at 10:43:01AM -0500, zuckbin wrote:

how to solve this ?
The configuration above should not result in an infinite loop.
Things to check in no particular order:

  • Make sure configuration you are working with is actually one
    loaded by nginx. That is, make sure you’ve done a configuration
    reload and it was successfull.

  • Make sure you aren’t testing your browser’s cache instead of
    current configuration. That is, make sure to clear cache before
    each test. Or, better yet, use telnet or curl for tests.


Maxim D.
http://nginx.org/

i forgot to say that i used pound on my server before to send traffic to
nginx

Maybe, there is a conflict with it

Posted at Nginx Forum:

On Tue, Mar 04, 2014 at 08:27:39AM -0500, zuckbin wrote:

Hi there,

this…

curl -i “http://www.aaa.com/

Location: http://www.aaa.com/

says that the config that you think nginx is using is not the config
that nginx is using.

You have a few other recent mails which probably have the same starting
cause.

Change things so that you know exactly which config file is being used,
and then put your intended config in that file and restart nginx.

Good luck with it,

f

Francis D. [email protected]

curl -i “http://www.aaa.com/
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 04 Mar 2014 13:25:24 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Keep-Alive: timeout=5
Location: http://www.aaa.com/

301 Moved Permanently

301 Moved Permanently


nginx

Posted at Nginx Forum:

i don’t understand why you said that is not the good conf file is used ?

how do you know this ?

Posted at Nginx Forum:

On Wed, Mar 05, 2014 at 03:18:31AM -0500, zuckbin wrote:

i don’t understand why you said that is not the good conf file is used ?

how do you know this ?

You request http://www.aaa.com/. You get a redirect to
http://www.aaa.com/.

Which part of the configuration you showed does a redirect to
http://www.aaa.com/?

f

Francis D. [email protected]