I have a website with two domains and one hosting server that worked fine with this two URL.
domains are www.jongeshadi.com and www.jongeshadi.ir.
I want when a user typed www.jongeshadi.irredirect to www.jongeshadi.com.
I Google it and find some solution such as change web config to:
<rewrite>
<globalRules>
<rule name="Redirects to www.jomgeshadi.com" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^jongeshadi.*(ir|com)$" />
<add input="{HTTP_HOST}" pattern="^(www.)?jonsgeshadi.(ir|com)$" />
<add input="{HTTP_HOST}" pattern="^www.jongeshadi.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.ir/{R:0}" />
</rule>
</globalRules>
</rewrite>
But it doesn't worked.any thing is mistake or is there other solution?
With modern version of IIS, the easiest way to achieve this is by using URL Rewrite 2.0. It can be installed as a package using Microsoft's Web Platform Installer.
Once you have the rewrite module installed, it adds a URL Rewrite feature in IIS Manager when the website is selected in the tree view.

Inside the URL Rewrite feature, choose "Add rule(s)..." from the right-hand side bar, and then choose to add a "Canonical domain name" rule. Specify the primary host name you want to be the one to display and hit OK.


That's all there is to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With