Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Amazon EC2 + 301 www redirection

0

56 views

I'm running a site on AmazonEC2 instance, and so far everything is ok, except a single glitch. When I navigate to

www.mysite.com/somepage.html

, browser happily opens the desired page. But when I try

mysite.com/somepage.html

, I go to the root of my site, i.e. to

www.mysite.com

LiveHTTPHeaders tells me that 301 redirection occurs. So here's the question: what configuration files do I need to change to make redirection respect URL path?

Also, I noticed that nginx does the redirection. Does it mean that redirection is happening outside of EC2 instance or not?

Thank you in advance.

asked June 19, 2011 6:23 pm CDT
posted via StackOverflow

1 Answers

1
 

You should have some kind of settings that is redirecting your request from http://mysite.com/ to http://www.mysite.com/

Following is kind of conf. settings you should find in your nginx.conf or inside /etc/nginx/sites-enabled/<site-vhost-name>

server {
  server_name example.com;
  rewrite ^/(.*) http://www.example.com/$1 permanent;
}

This tells NGINX to redirect request from http://mysite.com/ to http://www.mysite.com/.

If yes?, then blindly remove those two lines of conf.

answered June 24, 2011 3:41 pm CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview