views:

28

answers:

1

Hello, 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?)

A: 

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 the wp_options table, the row has option_id of 2 for me and option_name of siteurl) to <some domain>.com, I changed that to <some domain>.com:8746 and it worked fine.

Zack