472,119 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 11009
Niheel
2,452 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
Dec 27 '21 #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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.