[iis] How to redirect a URL path in IIS?

In IIS 6.0, is there an easy way to re-direct requests to a folder to another folder, while preserving the rest of the path.

e.g.

If I have moved the content from:
mysite.org.uk/stuff
to
stuff.mysite.org.uk/

Can I automatically redirect requests for specific pages like
mysite.org.uk/stuff/countrybriefing/tanzania/travel.html
to
stuff.mysite.org.uk/countrybriefing/tanzania/travel.html

I know that .htaccess can do things like this in Apache, is there an equivalent in IIS?

This question is related to iis redirect iis-6

The answer is


Here's the config for ISAPI_Rewrite 3:

RewriteBase /

RewriteCond %{HTTP_HOST} ^mysite.org.uk$ [NC]

RewriteRule ^stuff/(.+)$ http://stuff.mysite.org.uk/$1 [NC,R=301,L]


If you have loads of re-directs to create, having loads of virtual directories over the places is a nightmare to maintain. You could try using ISAPI redirect an IIS extension. Then all you re-directs are managed in one place.

http://www.isapirewrite.com/docs/

It allows also you to match patterns based on reg ex expressions etc. I've used where I've had to re-direct 100's of pages and its saved a lot of time.


Format the redirect URL in the following way:

stuff.mysite.org.uk$S$Q

The $S will say that any path must be applied to the new URL. $Q says that any parameter variables must be passed to the new URL.

In IIS 7.0, you must enable the option Redirect to exact destination. I believe there must be an option like this in IIS 6.0 too.


Examples related to iis

ASP.NET Core 1.0 on IIS error 502.5 CS1617: Invalid option ‘6’ for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default Publish to IIS, setting Environment Variable IIS Manager in Windows 10 The page cannot be displayed because an internal server error has occurred on server The service cannot accept control messages at this time NuGet: 'X' already has a dependency defined for 'Y' Changing project port number in Visual Studio 2013 System.Data.SqlClient.SqlException: Login failed for user "This operation requires IIS integrated pipeline mode."

Examples related to redirect

React-Router External link Laravel 5.4 redirection to custom url after login How to redirect to another page in node.js How to redirect to an external URL in Angular2? How to redirect to a route in laravel 5 by using href tag if I'm not using blade or any template? Use .htaccess to redirect HTTP to HTTPs How to redirect back to form with input - Laravel 5 Using $window or $location to Redirect in AngularJS yii2 redirect in controller action does not work? Python Requests library redirect new url

Examples related to iis-6

How to allow download of .json file with ASP.NET IIS Request Timeout on long ASP.NET operation Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected] Login failed for user 'DOMAIN\MACHINENAME$' Socket transport "ssl" in PHP not enabled What causes an HTTP 405 "invalid method (HTTP verb)" error when POSTing a form to PHP on IIS? How to redirect a URL path in IIS? What does 'IISReset' do?