<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 3, 2014 at 12:22 AM, Kurogane <span dir="ltr"><<a href="mailto:nginx-forum@nginx.us" target="_blank">nginx-forum@nginx.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello All,<br>
<br>
I am facing some issue regarding nginx redirection i'm unable to fix it. I<br>
want to create redirect non www to www but always redirect me to<br>
default_server how i can fix this issue.<br>
<br>
This is what i have<br>
<br>
server {<br>
                listen 80 default_server;<br>
                server_name localhost;<br>
                root /home/nginx/default/public;<br>
<br>
....<br>
}<br>
<br>
<br>
server {<br>
        listen 80;<br>
        server_name <a href="http://domain.com" target="_blank">domain.com</a>;<br>
        return 301 $scheme://<a href="http://www.domain.com" target="_blank">www.domain.com</a>$request_uri;<br>
        root  /home/user/public_html;<br>
....<br>
}<br>
<br>
When i go to <a href="http://domain.com" target="_blank">domain.com</a> or <a href="http://www.domain.com" target="_blank">www.domain.com</a> i got default document root<br>
<br>
If i change server_name <a href="http://domain.com" target="_blank">domain.com</a>; to server_name <a href="http://domain.com" target="_blank">domain.com</a><br>
<a href="http://www.domain.com" target="_blank">www.domain.com</a>; i got redirect loop issue.<br>
<br>
Then how i suppose to solve this problem.<br></blockquote><div><br></div>Do you have another server block with `server_name <a href="http://www.domain.com">www.domain.com</a>` which supposed to handle the actual request?<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,253713,253713#msg-253713" target="_blank">http://forum.nginx.org/read.php?2,253713,253713#msg-253713</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>regards,<br>Nurahmadie<br>--<br>
</div></div>