Link to home
Start Free TrialLog in
Avatar of street9009
street9009Flag for United States of America

asked on

Subdomain Redirect Issue

I hope I have this in the correct topics...

I have inherited a web application that I cannot for the life of me figure out. It's on an IIS 7.5 web server that has multiple domains pointed to it. I am trying to set up a development environment (live site is www.domain.com and test site will be dev.domain.com). For some reason, when I visit dev.domain.com, it always redirects to www.domain.com and I cannot figure out why. The bindings of the live site do not include dev.domain.com on the web server (even though when you visit that in a browser, it appears to still load files from the live site). So there has to be something I'm not seeing.

What all do I need to check so I can get this development environment set up and working properly? What am I forgetting that could be doing this?
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

I would look in the web.config to see if there are any IIS Rewtite rules in place.  Common redirects are for things like redirecting domain.com to www.domain.com.

If you post the web.config, we should be able to see if this is the issue.

What language was the website written in?  ASP.NET, ASP, PHP, static HTML?

Dan
Avatar of street9009

ASKER

I didn't see anything in web.config, but I've attached it just in case. I'm not 100% confident in all things web.config related (I hate regular expressions).

The website is written in PHP (which I have a pretty fair knowledge of). It's not even getting to index.php before the redirect takes place (I put a die; statement on the first line as a test).

There's also a down.htm file in the root that I renamed to down.html, but down.htm still loads when I go to dev.domain.com/down.htm (oddly enough the domain stays dev.domain.com for that file only).

It's like the bindings are wrong, but they don't appear to be. The dev environment is configured to reply to all IPs on dev.domain.com so it should be working.
web.config
I do not see any URL Rewrite rules doing a www redirect of any type.

I also noticed that there is no .php file as a default document.  Odd for a site using PHP.  What is the down file doing?  what is the content of the file... is there any JavaScript in the file?

Dan
The down.html file is just a file that's there for maintenance type purposes. It appears it was literally typed in Microsoft Word and then saved as an HTML document. My guess is when the application has trouble, they've been told to rename the file to down.html to keep people out of it.
Ok, then I would venture a guess that the redirect is in the PHP code.  I'd guess there is some form of request routing being done on all inbound hits on whatever the main php file is.  Typical of an MVC framework.

Dan
How would that redirect still be working with a die; on the first line of the index.php file?
Oh wait, one other place to check.  In IIS Manager, select the site in question, open the feature called "HTTP Redirect" and see if the feature is configured and enabled.

If that is empty, I would check the HTTP Redirect feature when the Sever Object is in focus.

Dan
It's not enabled on the server or the site.
Have you tried to use any browser developer tools while broswing the dev site to see whats happening during the request process?

If you are sure that the requests are not getting down into the PHP code, then I am somewhat at a loss as to where a http redirect is coming from.

Dan
I haven't. Which tools would you recommend?
The latest Firefox browser with their Dev Tools.  Chrome works fine too but I like the FF setup better.

Dan
Okay I have that loaded. What should I be looking for?
Open a new teb, then open the dev tools.  Enter the URL and hit enter.  The dev tools should show http conversation that occurred between the browser and the web site.  Then Network tab should be of interest.  Clicking on each request, you should see the raw headers in the right-hand panel.

Also, can you post a screenshot of the IIS Manager with the "Sites" object in focus?  I'd like to see how the sites appear in the manager.

Dan
I think there must be something in the bindings and it's never getting to the dev.domain.com site. I can completely stop that website and it still loads.

Can firewalls get a request on port 80, but communicate with the server on a different port? There are two odd bindings on the live site (http on port 8080 and https on 8443).
If you post the screenshot I mentioned above, I think we can solve the issue.

Firewall usually just allow predefined port thru to a destination IP address.  Smaller combo device can do port forwarding which may change the destination port but the user usually doesn't see this.

I think its the way the site's IP addresses are bound.

Dan
Screenshot is attached. I had to blank out the domain names for privacy purposes. But basically we're trying to copy site 11 to site 15. Site 11 seems to be overriding 15.

As you can see, there are only a handful started.
IIS-Sites.jpg
Did you do an extended search through your files for this domain to see if it's hardcoded in one of your files such as appcontroller or bootstrap for example.
Also
What is the result when you enter XYZ.domain.com?
My thinking is that possibly you have a set of defined domains that are relocated and when a domain that is not recognized is entered then it relocates anyway - as in a trailing else statement
xyz.domain.com doesn't resolve, so we're good there.

I don't see how it could be in any one of the files since it still loads the live site even when the dev site is stopped. I have searched them, however, to be sure. I actually put a die; statement on line 1 of index.php so I can tell when it actually gets there. It hasn't.
It doesn't seem possible that you have the dev site stopped and when you enter dev.domain.com that it relocate somewhere.
That would indicate that dev isn't truly stopped.
Or that dev is listed under the host headers of another site that is still running.
Look at the host headers for all your sites.
Check the screenshot I posted for Dan. The bindings are all there and dev.domain.com isn't in any of them.
I did see the screenshot
I just wanted to make sure that it wasn't there.
Because you know we can't see if it was there and you accidentally hit it with white-out ...

Does your server have a default website?
It does not.

Also, I only blanked out the domain, not the TLDs or subdomains.
Well that's a tough one...

Maybe it's configured on a different machine?
Have you investigated your DNS?
I haven't, but if I stop the Site numbered 11 in that screenshot, it gives a "Bad Hostname" error when going to the dev subdomain. That should mean it's pointing to that server, correct?
Yes
Who is your name server?
I'd start investigating from that point.
It's someone called Stable Transit. I'd never heard of them prior to this. What, specifically, would you investigate?
Looks like that's the nameserver when using Rackspace Cloud Servers
Contact them to find out if any of your domains are being directed by their name servers
I found out that's correct. What should I be looking for?
Well look through all the records that have to do with your domains but it looks like somebody has entered dev.domain.com on these records you haven't accessed.
Sorry, I didn't get an alert that you posted the binding info.

IMO, your issue is in the way you have the bindings for all of the sites setup.  You are using the following bindings (1 or more) on your sites:

*:80 (http)
*:443 (https)
*:8080 (http)
*:8443 (https)

---- in Microsoft IIS speak, this is referred to as "All Unassigned"

The binding definition above usually causes issues where multiple sites are hosted on a single server.  This allows IIS to service an http request on ANY ip address it feels fit to use.  If you have more than 1 IP on the server, it can use any available

The recommendation I always make, set the site binding to the IP address that the host name resolves to in DNS.  This way it prevents IIS from choosing the wrong site content.

Dan
Hey Dan,

That's typically the way I set them up as well (obviously it's required when using HTTPS). I'll get with those that manage the firewall and see if we can get that going.

However, shouldn't the host headers work even if it is on the same IP? Typically when I have a website that doesn't require HTTPS, I don't waste an IP on it and use the host headers, like is done here.
You aren't wasting an IP, just forcing a site to respond on a specific IP.  *:80 means IIS is allowed to use any available (unassigned) IP it wants, to service an inbound http request.  And since you need to create a DNS record of some sort (either an A or a CNAME) that corresponds to your sites URL, its best to assign an IP directly.
 
With only a single IP on a box, you should always pick an IP and use Host Names (host headers).

Dan
Oh, so you're saying instead of "All Unassigned", just give them all the same internal IP (server only has one)?
ASKER CERTIFIED SOLUTION
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was it. It's working perfectly now.

Thank you!
glad u guys got it sorted ...