Nginx server matching too many URLs
I've got a domain example.com
and an "alternative" of some-example.com
. I'm trying to direct traffic from some-example.com
to example.com
using a simple server declaration in nginx as follows:
server {
listen 80;
server_name some-example.com;
rewrite ^/(.*) http://example.com/$1 permanent;
}
I'm not 100% sure if this is the right rule, but I've got another vhost on the server, this isn't where the problem is, but it's necessary to understand the issue I'm having.
server {
listen 8745;
server_name localhost;
<other stuff goes here>
}
Hitting <my server IP>:8745
will go to that vhost, that works as intended. However I've got another vhost like this:
server {
listen开发者_运维百科 8746;
server_name localhost;
<other stuff goes here>
}
But all of my requests to <my server IP>:8746
hit example.com
. I'm... baffled, I don't really grok nginx, so any help would be appreciated as to why this is happening. I mentioned that rule in the beginning because I'm thinking it has something to do with this. If additional information is needed I can supply it.
(Also, would this be better for Server Fault?)
I asked this on Server Fault also, however I found out the cause on my own. The below excerpt is pulled from this question.
It turns out this isn't an nginx issue. I probably should've noted that
<my server IP>:8746
runs a Wordpress installation; Wordpress has an option set (in thewp_options
table, the row hasoption_id
of 2 for me andoption_name
ofsiteurl
) to<some domain>.com
, I changed that to<some domain>.com:8746
and it worked fine.
精彩评论