How To redirect subdomain to domain

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SofiaValencia
    New Member
    • Dec 2021
    • 2

    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
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2433

    #2
    You will need to make sure you have the IIS rewrite module installed and then you have edit your Web.config file



    In the rewrite section you will have to add something like this
    Code:
          <rewrite>
                 <rules>
                     <rule name="redirect" stopProcessing="true">
                         <match url="^(.*)$" />
                         <action type="Redirect" url="https://domain.com/{R:0}" appendQueryString="true" />
                         <conditions>
                             <add input="{HTTP_HOST}" pattern="^www.domain.com$" />
                         </conditions>
                     </rule>
                 </rules>
             </rewrite>
    Here's the Microsoft documentation for using the URL rewrite module.
    This section of the documentation applies to the URL Rewrite 2.0 for IIS 7. URL Rewrite 2.0 for IIS 7 and above is an incremental release that includes all...
    niheel @ bytes

    Comment

    Working...