469,955 Members | 1,740 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,955 developers. It's quick & easy.

How To redirect subdomain to domain

Hello Everybody,

I want to redirect my site from without www to www..I have IIS server.
So what I need when user come on my site no error of 'page not found' (i.e. error 404 ) should be occured..
Can you help me? anyone tell..
Thanks in advance
Dec 18 '21 #1
1 9797
Niheel
2,442 Expert Mod 2GB
You will need to make sure you have the IIS rewrite module installed and then you have edit your Web.config file

https://www.iis.net/downloads/microsoft/url-rewrite

In the rewrite section you will have to add something like this
Expand|Select|Wrap|Line Numbers
  1.       <rewrite>
  2.              <rules>
  3.                  <rule name="redirect" stopProcessing="true">
  4.                      <match url="^(.*)$" />
  5.                      <action type="Redirect" url="https://domain.com/{R:0}" appendQueryString="true" />
  6.                      <conditions>
  7.                          <add input="{HTTP_HOST}" pattern="^www.domain.com$" />
  8.                      </conditions>
  9.                  </rule>
  10.              </rules>
  11.          </rewrite>
  12.  
Here's the Microsoft documentation for using the URL rewrite module.
https://docs.microsoft.com/en-us/iis...rite-module-20
4 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.