nginx相关的问题

[warn]: conflicting server name "15-1688.com" on 0.0.0.0:80, ignored

[warn]: conflicting server name "15-1688.com" on 0.0.0.0:8090, ignored

一个nginx的配置来自http://www.oschina.net/bbs/thread/3782

1. 在 Apache 的写法

RewriteCond  %{HTTP_HOST}  nginx.org<br />RewriteRule  (.*)          http://www.nginx.org$1<br />

在 Nginx 可以对应写成:

server {<br />    listen       80;<br />    server_name  www.nginx.org  nginx.org;<br />    if ($http_host = nginx.org) {<br />        rewrite  (.*)  http://www.nginx.org$1;<br />    }<br />    ...<br />}<br />

但 Nginx 作者更建议的方法是:

server {<br />    listen       80;<br />    server_name  nginx.org;<br />    rewrite   ^  http://www.nginx.org$request_uri?;<br />}<br /><br />server {<br />    listen       80;<br />    server_name  www.nginx.org;<br />    ...<br />}
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13px; white-space: normal; line-height: 12px;"><div id="question-header" style="margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; width: 960px; border-bottom-style: solid; border-bottom-color: #555555; background-position: initial initial; background-repeat: initial initial; padding: 0px;"><h1 style="margin-top: 0px; margin-right: 0px; margin-bottom: 7px; margin-left: 0px; font-size: 23px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; font-weight: bold; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;"><a class="question-hyperlink" style="font-size: 23px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; text-decoration: none; cursor: pointer; font-weight: bold; line-height: 15px; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" href="/questions/180800/how-to-permanently-redirect-port-8080-url-to-port-80-using-nginx">How to permanently redirect port 8080 URL to port 80 using nginx</a></h1></div><div id="mainbar" style="margin-top: 0px; margin-right: 0px; margin-bottom: 40px; margin-left: 0px; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; float: left; width: 735px; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;"><div id="question" style="font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; width: 730px; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><div class="everyonelovesstackoverflow" style="margin-top: 0px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;"><a style="font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #10456a; text-decoration: none; cursor: pointer; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" rel="nofollow" href="http://ads.stackoverflow.com/a.aspx?Task=Click&ZoneID=7&CampaignID=1523&AdvertiserID=218&BannerID=2347&SiteID=2&RandomNumber=235832137&Keywords=nginx%2credirect%2c301%2cx-user-registered" target="_Blank"><img style="font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;" src="http://ads.stackoverflow.com/ads/firehost_LB_20100714.png" border="0" alt="" width="728" height="90" align="Center" /></a></div></div></div></span>

up vote 0 down vote favorite

Because of my carelessness, I put http://www.domain.com:8080/xxx/index.html on the internet. I don't want to lose that traffic, so i want to permanent redirect that url to http://www.domain.com/xxx/index.htmlCan nginx achieve this? thanks

link | flag

<span style="font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13px; white-space: normal; line-height: 12px;"><div id="mainbar" style="margin-top: 0px; margin-right: 0px; margin-bottom: 40px; margin-left: 0px; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; float: left; width: 735px; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;"><div id="answers" style="padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; width: 730px; background-position: initial initial; background-repeat: initial initial; margin: 0px; border: 0px initial initial;"><div id="answers-header" style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: 730px; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;"><div class="subheader answers-subheader" style="margin-top: 0px; margin-right: 0px; margin-bottom: -10px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; border-bottom-style: solid; border-bottom-color: #666666; height: 34px; width: 730px; clear: both; background-position: initial initial; background-repeat: initial initial; padding: 0px;"><h2 style="font-size: 22px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; font-weight: bold; float: left; line-height: 34px; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">1 Answer</h2><div id="tabs" style="font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; float: right; font-weight: bold; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><a style="margin-top: 8px; margin-right: 8px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 11px; padding-bottom: 0px; padding-left: 11px; font-size: 12px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: inherit; color: #777777; text-decoration: none; cursor: pointer; display: block; float: left; height: 24px; line-height: 22px; background-position: initial initial; background-repeat: initial initial; border: 1px solid #ffffff;" title="Answers in the order they were given" href="/questions/180800?tab=oldest#tab-top">oldest</a><a style="margin-top: 8px; margin-right: 8px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 11px; padding-bottom: 0px; padding-left: 11px; font-size: 12px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: inherit; color: #777777; text-decoration: none; cursor: pointer; display: block; float: left; height: 24px; line-height: 22px; background-position: initial initial; background-repeat: initial initial; border: 1px solid #ffffff;" title="Most recent answers first" href="/questions/180800?tab=newest#tab-top">newest</a><a class="youarehere" style="margin-top: 3px; margin-right: 8px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 11px; padding-bottom: 0px; padding-left: 11px; font-size: 15px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: black; text-decoration: none; cursor: pointer; border-top-color: #777777; border-right-color: #777777; border-bottom-color: #fffcf7; border-left-color: #777777; display: block; float: left; height: 30px; line-height: 28px; background-position: initial initial; background-repeat: initial initial; border: 1px solid initial;" title="Answers with the most votes first" href="/questions/180800?tab=votes#tab-top">votes</a></div></div></div></div></div></span>

up vote 1 down vote
<code style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">server </span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">{</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><br />    listen www</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">.</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">domain</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">.</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">com</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">:</span><span class="lit" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #4e0000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">8080</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">;</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><br />    server_name  www</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">.</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">domain</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">.</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">com</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">;</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><br />    rewrite </span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">^</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"> http</span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">:</span><span class="com" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: gray; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">//www.domain.com permanent;    </span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><br /></span><span class="pun" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #888888; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">}</span><span class="pln" style="font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #333333; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;"><br /></span></code>

Should do it.

link | flag

你可能感兴趣的:(nginx)