Redirect only root of siteRSS

3 replies

Last post Oct 29, 2019 01:57 AM by Jalpa Panchal

  • Redirect only root of site

    Oct 28, 2019 04:12 PM|christopher877|LINK

    I am trying to create a redirect for an IIS 8.5 site where it ONLY redirects the domain and nothing below it. For example, I am looking to redirect 'https://mysite.com' to 'abc.com' and nothing else. Using the HTTP redirect module, I was able to get it to partially work. I configured it to only redirect requests to content in the root directory but I only want the domain name to redirect not the pages within. For example, https://mysite.com/pageabc.html was still redirecting when I didn't want it to. See examples below.

    examples:
    https://mysite.com - redirect
    https://mysite.com/PDFs/abc.pdf - do not redirect
    https://mysite.com/pageabc.html - do not redirect

  • Re: Redirect only root of site

    Oct 28, 2019 05:17 PM|lextm|LINK

    Lex Li
    https://lextudio.com
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Redirect only root of site

    Oct 28, 2019 07:18 PM|christopher877|LINK

    lextm

    Please use URL Rewrite module to achieve this,

    https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

    I can't seem to get it to work using the rewrite module. 

  • Re: Redirect only root of site

    Oct 29, 2019 01:57 AM|Jalpa Panchal|LINK

    Hi,

    You could use below URL rewrite rule:

     <rule name="domian redirect" stopProcessing="true">
                        <match url="^$" />
                        <conditions>
                            <add input="{HTTPS}" pattern="on" />
                            <add input="{HTTP_HOST}" pattern="^www.sample1.com$" />
                        </conditions>
                        <action type="Redirect" url="http://www.sample2.com" />
                    </rule>

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.