To redirect mydomain.com to www.mydomain.com, edit your web.config file and add the following segment under the <system.webserver> section. Ensure you modify the words “mydomain.com” with your appropriate domain name.
- <rewrite>
- <rules>
- <rule name="Redirect http://mydomain.com to http://www.mydomain.com HTTP" patternSyntax="ECMAScript" stopProcessing="true">
- <match url=".*"></match>
- <conditions>
- <add input="{HTTP_HOST}" pattern="^mydomain.com$"></add>
- <add input="{HTTPS}" pattern="off"></add>
- </conditions>
- <action type="Redirect" url="http://www.mydomain.com/{R:0}" redirectType="Permanent" appendQueryString="true"></action>
- </rule>
- </rules>
- </rewrite>

shyamala sPosted Jun 25, 2020, 9:18 PM
What if i have changed from http://domain to http://www.domain; google search console giving an error Duplicate without user-selected canonical
Bhavik ShahPosted May 6, 2020, 5:05 AM
What if I want to change http://www.domain.com/Default.aspx to http://www.domain.com
harsh harshPosted Aug 30, 2019, 4:07 AM
Hello I implement this and work fine on http://www.domain.com but when we enter domain like http://domain.com then it will not redirect to https://www.domain.com
Former memberPosted Feb 5, 2019, 4:58 AM
Not working for me :(
Ninh NguyễnPosted Oct 19, 2018, 11:25 PM
Hi Sir, I get an error 500 - Internal server error.What is the cause?
saroj dsaPosted Aug 7, 2018, 2:27 AM
Hi Sir, Will it work for https?
Mandar DeodharPosted Feb 5, 2018, 6:30 AM
Hi Nitesh, will this work with MVC as well ?