Mobile app version of vmapp.org
Login or Join
Kimberly868

: How to handle CNAME host redirect to virtual directory? I have an internal website and virtual directory http://server2012/logs. I created a CNAME on my DNS server as LOGS -> server2012. I would

@Kimberly868

Posted in: #Cname #Iis7 #Localhost #Redirects #UrlRewriting

I have an internal website and virtual directory server2012/logs. I created a CNAME on my DNS server as LOGS -> server2012. I would like to set it up so that LOGS redirects to server2012/logs. Ideally, I would still want it so that all pages appear in the browser as being off from the LOGS URL. So LOGS/network.html?site=32 is what is displayed in the browser, but it is really being served from server2012/logs/network.html?site=32. I've looked at URL rewrite, but can't seem to get to work.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Kimberly868

3 Comments

Sorted by latest first Latest Oldest Best

 

@Bethany197

Create a Condition: {HTTP_HOST} / Matches the Pattern / LOGS

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="LOGS Redirect" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="LOGS" />
<conditions>
<add input="{HTTP_HOST}" pattern="LOGS" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

10% popularity Vote Up Vote Down


 

@Eichhorn148

I believe you can do this easily enough in IIS 7.x:


Create the DNS alias/CNAME pointing logs to server2012 --> You've already done this.
Create a new site on the server2012 that responds to the host header logs (or, better yet, the FQDN like logs.domain.tld)
Now you have two options:

a. Use IIS 7's basic redirection feature to direct the URLS to server2012/logs/... --> This will change the URL the user sees, not mask it like you were hoping.

b. Use the more advanced URL Rewrite module to mask the redirect/rewrite so it still looks like you're browsing logs/...

Good luck!

10% popularity Vote Up Vote Down


 

@Lengel546

I'm not sure this is at all possible. The LOGS need to be its own virtual server.

So essentially, set up a new virtual web server (if you're using Apache this is a breeze,) with it's root folder pointing to the same folder as this one does: in server2012/logs/.

Then, set up your DNS (bind?) to aim the internal traffic from LOGS/ to the physical server.

To tie it all up, simply make the new virtual web server respond to only LOGS/, and the server2012 web server, only respond to that.

I run this type of set up at my home office for developing client sites, and it's been running 20 or more sites at once for years without headaches.

Bare in mind, the /logs/ folder will still be accessible through server2012/logs/. If this is unwanted, you can probably fix that with the .htaccess file.

Edit: If it weren't clear already, this is obviously not a CNAME fix - you might as well us an A record. :)

Hopefully that helps.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme