开发者

Amazon EC2 + 301 www redirection

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 oc开发者_开发问答curs. 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜