How to handle CNAME host redirect to virtual directory?

How to handle CNAME host redirect to virtual directory? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the How to handle CNAME host redirect to virtual directory? error on your web browser. Problem :


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


Solution :

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 http://server2012/logs/.



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



To tie it all up, simply make the new virtual web server respond to only http://LOGS/, and the http://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 http://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.



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




  1. Create the DNS alias/CNAME pointing logs to server2012 --> You've already done this.


  2. Create a new site on the server2012 that responds to the host header logs (or, better yet, the FQDN like logs.domain.tld)


  3. Now you have two options:



    a. Use IIS 7's basic redirection feature to direct the URLS to http://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 http://logs/...




Good luck!



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>

We hope that this article has helped you resolve the redirects, url-rewriting, iis7 error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=