URL Rewrite subdomain with wildcards to home page

Discussion in 'Site Programming, Development and Design' started by CancunMX, Nov 7, 2012.

  1. Hi, I have searched all over and cannot find the solution, so maybe you guys can help. I am using URL Rewrite...I have many old urls like http://archives.cancunandrivieramaya.com/archives/cancun.cgi/md/read/id/xxxx that I want to redirect to the home page http://www.cancunandrivieramaya.com.

    Code:
    <rule name="Redirect archives" stopProcessing="true">
    <match url="^archives.cancunandrivieramaya.com/archives/(.*)$" ignoreCase="false" />
    <action type="Redirect" url="http://www.cancunandrivieramaya.com/{R:1}" />
    </rule>
    However this does not work. Am I missing something? The subdomain named "archives" does not exist on the new Winhost server. I think the problem I have is that I am trying to redirect a subdomain with wildcards. Any help would be very much appreciated.
     
    Last edited by a moderator: Oct 14, 2015
  2. ComputerMan

    ComputerMan Winhost Staff

    Try adding the Subdomain (archives) in the control panel.

    To do this please follow the steps below:

    Login to the control panel.

    Click on "Sites" tab at the top.

    Click on "Manage" next to the site you wish to manage.

    Click on "Subdomain Manager"

    Then add the subdomain "archives".

    Once added. This will create a DNS entry in our DNS Manager. And it will also create the host header on the web server.
     
  3. Fixed!

    You were right! Thanks to this article by Altaf Khatri http://www.altafkhatri.com/Technical/Configure/How-to-publish-or-host-subdomain-on-Winhostcom/Solution-resolution I was able to follow his step-by-step instructions for setting up the subdomain on Winhost, then I added this rule to the web.config file:
    Code:
    <rule name="archive redirect" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^www\.archives\.cancunandrivieramaya\.com$" />
              </conditions>
              <action type="Redirect" url="http://www.cancunandrivieramaya.com/" />
            </rule>
    
            <rule name="archives 2" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^(www\.)?archives\.cancunandrivieramaya\.com$" />
                <add input="{PATH_INFO}" pattern="^/archives/($|/)" negate="true" />
              </conditions>
               <action type="Redirect" url="http://www.cancunandrivieramaya.com/" />
            </rule>
    Works like a charm! Thank you!
     
    Last edited by a moderator: Oct 14, 2015

Share This Page