How to Use IIS URL Rewrite to Redirect to Another Domain
Автор: vlogize
Загружено: 2025-09-22
Просмотров: 4
                Описание:
                    Learn how to effectively set up IIS URL Rewrite rules to redirect users to another domain seamlessly. This guide breaks down the process step-by-step for clarity.
---
This video is based on the question https://stackoverflow.com/q/62991741/ asked by the user 'Cloud-Lover' ( https://stackoverflow.com/u/7420665/ ) and on the answer https://stackoverflow.com/a/63000333/ provided by the user 'Cloud-Lover' ( https://stackoverflow.com/u/7420665/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.
Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: IIS using (URL Rewrite) to Redirect to another domain
Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.
If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
How to Use IIS URL Rewrite to Redirect to Another Domain
If you're managing a website and need to redirect visitors from one URL to another, the IIS URL Rewrite module is an essential tool. A common scenario is when you're transitioning users from a legacy domain to a new one. In this guide, we’ll walk you through the steps to successfully set up a redirect from https://www.domain.info/cms-cp/login.... to https://www-server2.domain.info/cms-c....
Understanding the Problem
You may find yourself in a situation where you want to direct users visiting a specific URL on one server to a corresponding page on another server. In our example, visitors trying to access https://www.domain.info/cms-cp/login.... should seamlessly be redirected to https://www-server2.domain.info/cms-c....
Some users might find the configuration not working initially, so let's explore the correct setup for your rewrite rules.
Solution Overview
To achieve this, we will set up an IIS URL Rewrite rule in the web.config file of your website. Below is the incorrect code that someone might have initially tried:
Initial Attempt
[[See Video to Reveal this Text or Code Snippet]]
Issues in the Initial Code
The <match> condition is overly broad and applies to all URLs.
The <conditions> block uses {HTTPS}, which is not appropriate for checking the host name.
Correct Configuration
Here is the revised and effective rule that should work correctly for the redirect:
Correct Rewrite Rule
[[See Video to Reveal this Text or Code Snippet]]
Key Changes Explained
Specific Match for URL:
The <match url="login.html" /> matches specifically when users try to access login.html.
Using {HTTP_HOST}:
The condition is set to check the host using {HTTP_HOST} which is more appropriate for host checking.
Ignore Case:
The ignoreCase="true" ensures that the rule works regardless of the case sensitivity of the URL.
Permanent Redirect:
The redirectType="Permanent" indicates that the redirect is permanent (HTTP status 301), which is better for search engine optimization (SEO).
Conclusion
Redirecting users from one domain to another using IIS URL Rewrite is straightforward when the rules are set up correctly. By following the recommended configurations above, you can ensure that your URLs redirect seamlessly, improving user experience and maintaining traffic to the new domain.
Feel free to refer back to this guide whenever you're setting up redirection to ensure it's done correctly!                
                
Повторяем попытку...
 
                Доступные форматы для скачивания:
Скачать видео
- 
                                Информация по загрузке: