Need to redirect files in one sub-directory to a different sub-directory in IISRSS

3 replies

Last post Jul 22, 2019 09:59 AM by Able

  • Need to redirect files in one sub-directory to a different sub-directory in IIS

    Jul 19, 2019 08:21 AM|Steve.S|LINK

    I recently consolidated several domains to one, and have in place 301 redirects from the 2 that are no longer used to the other. However seems I didn't account for a number of specific files in sub-directories, which I realized today are giving 404s. I came across this web config code from Ross Hawkins, below, but am unsure how to apply it, what folder it should be in, or if it solves my problem.

    There are 2 scenarios. In one, the files are in a sub-directory of the main website and i want to redirect them to a specific sub-directory, and in the other, they are in a sub-directory of one of the domains that are no longer used (but still on my server) and i want to redirect them to specific files in a sub-directory on the main website.

    I've Googled this quite a bit, and found web config code but not sure if what I've seen will do what I want. From Ross Hawkins:

    <rule name="toservices" stopProcessing="true">
    <match url="^(analysis-design|custom-development|webhosting|websites|video).*" ignoreCase="true"/>
    <action type="Redirect" url="/services/" redirectType="Permanent" appendQueryString="true" />
    </rule>

    thanks for any help!

    Steve

  • Re: Need to redirect files in one sub-directory to a different sub-directory in IIS

    Jul 19, 2019 03:21 PM|Chris Becke|LINK

    The config in question is a rule for Application Request Routing. A IIS module you should really find in Web Package Installer and install as it does make scenarios like yours so much easier to deal with.
  • Re: Need to redirect files in one sub-directory to a different sub-directory in IIS

    Jul 19, 2019 05:08 PM|Steve.S|LINK

    Thank you, Chris, but this seems a fairly simple scenario that a rule, something similar to the one I posted,  should be able to handle.

  • Re: Need to redirect files in one sub-directory to a different sub-directory in IIS

    Jul 22, 2019 09:59 AM|Able|LINK

    Hi steve,

    According to your description,do you want to redirect the url in the same sub-directory? So does it have index.html in the target sub-directory?It will redirect the index.html by default.

    Best Regards

    Able 

    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.