non-www to www redirect in web.config

This post is basically for who need to redirect non-www to www url in windows hosting.

In web.config file as below code:


<system.webServer>
<rewrite>
<rules>
<rule name=”Redirect domain.com to www.domain.com HTTP” patternSyntax=”ECMAScript” stopProcessing=”true”>
<match url=”.*” />
<conditions>
<add input=”{HTTP_HOST}” pattern=”^domain.com$” />
<add input=”{HTTPS}” pattern=”off” />
</conditions>
<action type=”Redirect” url=”http://www.domain.com/{R:0}” redirectType=”Permanent” appendQueryString=”true”/>
</rule>
<rule name=”Redirect domain.com to www.domain.com HTTPS” patternSyntax=”ECMAScript” stopProcessing=”true”>
<match url=”.*” />
<conditions>
<add input=”{HTTP_HOST}” pattern=”^domain.com$” />
<add input=”{HTTPS}” pattern=”on” />
</conditions>
<action type=”Redirect” url=”https://www.domain.com/{R:0}” redirectType=”Permanent” appendQueryString=”true”/>
</rule>
</rules>
</rewrite>
</system.webServer>

In above code please note there are two rules used one for http and another for https. To avoid clashing of http and https in same rule, here used two separate pattern.

Hope it work for you guyz…!!

Previous Post

OpenCart 301 Redirect Not Working ?_route_=

Next Post

Enable gzip compression

54 comments

  1. whoah this blog iss excellent i like studying your articles.

    Keep up the great work! You realize, lots of persons are huntinng round
    for this information, you cann help them greatly.

  2. It’s awesome to go to see this web site and reading the views of all colleagues on the topic of this piece of writing, while I am also
    zealous of getting experience.

    1. Beatrice says:

      Deep thought! Thanks for coibirtutnng.

  3. Great post. I used to be checking continuously this blog and I am inspired!
    Extremely useful info specifically the closing section 🙂
    I maintain such information much. I used to be seeking this certain information for a very long time.

    Thank you and best of luck.

  4. .12m12Ll27 says:

    Thanks for your marvelous posting! I definitely enjoyed reading it, you might be a great
    author. I will remember to bookmark your blog and will often come back
    someday. I want to encourage yourself to continue your great work, have
    a nice morning!

    1. Yamary says:

      Filyanl! This is just what I was looking for.

  5. link vao w88 says:

    Yes! Finally someone writes about ca cuoc.

  6. facebook says:

    If some one desires expert view on the topic of running a blog then i advise him/her to
    go to see this blog, Keep up the pleasant job.

  7. Hi there, after reading this amazing post i am as well cheerful to share my experience
    here with colleagues.

  8. Wow, awesome blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your site is magnificent,
    as well as the content!

  9. Just want to say your article is as surprising.
    The clearness in your post is just spectacular and i could assume you’re an expert on this
    subject. Fine with your permission allow me to grab your RSS feed
    to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.

    1. Webpioneer says:

      Thank you.
      Currently RSS is not using on site. will update you once it implemented.

      Thank you once again.

    2. Ethica says:

      An inelltigent point of view, well expressed! Thanks!

  10. Excellent post. I was checking continuously this
    blog and I’m impressed! Very helpful info specially the last part
    🙂 I care for such information much. I was seeking this certain information for a very long time.
    Thank you and good luck.

    1. Conyers says:

      Furrealz? That’s maluelovsry good to know.

  11. KR Robot says:

    Having read this I believed it was rather enlightening.
    I appreciate you spending some time and energy to put this informative article together.
    I once again find myself personally spending way too much time both reading and posting comments.
    But so what, it was still worth it!

  12. Good way of telling, and pleasant paragraph to get data concerning my presentation focus, which i am going to deliver
    in school.

    1. Webpioneer says:

      Way to go…

  13. I am extremely inspired with your writing skills as neatly as with the structure in your weblog.
    Is this a paid subject or did you modify it yourself?
    Either way keep up the excellent high quality writing, it is uncommon to look a nice weblog
    like this one today..

  14. Very good information. Lucky me I came across your site by
    accident (stumbleupon). I have book-marked it for later!

    1. Webpioneer says:

      Great.

      1. Marlie says:

        Wow! Talk about a posting knocking my socks off!

    1. Webpioneer says:

      Thank you

      1. Crissy says:

        So much info in so few words. Tosolty could learn a lot.

  15. I got this web page from my pal who shared with me about
    this site and now this time I am browsing this web page and reading very informative content
    here.

    1. Webpioneer says:

      Thanks

    2. Sticky says:

      I really appreciate free, succinct, reliable data like this.

  16. My brother recommended I would possibly like this website.
    He used to be entirely right. This submit actually made my day.
    You cann’t believe just how much time I had spent for this information!
    Thanks!

    1. Webpioneer says:

      Thanks

      1. Jennica says:

        I have been so beelrdwied in the past but now it all makes sense!

  17. I think this is among the most significant information for me.
    And i’m satisfied reading your article. However want to
    commentary on some basic issues, The site style is wonderful, the articles is actually nice :
    D. Just right activity, cheers

    1. Aslan says:

      What a pluesare to meet someone who thinks so clearly

  18. Thank you for another magnificent post. The place
    else could anybody get that type of information in such an ideal method of writing?
    I have a presentation next week, and I’m at the
    look for such information.

    1. Webpioneer says:

      Thank you. All the best.

      Reagrds

    2. Cami says:

      BS low – raniitaloty high! Really good answer!

  19. Jahlin says:

    It’s a pity you do1#8&2n7;t have a donate button! I’d most certainly donate to this brilliant blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account. I look forward to brand new updates and will talk about this site with my Facebook group. Chat soon!

  20. Simply wish to say your article is as astonishing.
    The clearness in your post is simply great
    and i could assume you are an expert on this subject.
    Well with your permission let me to grab your RSS feed to keep updated with forthcoming post.
    Thanks a million and please carry on the rewarding work.

  21. homepage says:

    I got this website from my friend who informed me concerning
    this site and at the moment this time I am visiting
    this website and reading very informative content here.

  22. You are so awesome! I do not believe I have read a single thing like that before.
    So wonderful to discover someone with a few genuine thoughts on this subject.
    Really.. thanks for starting this up. This web site is one
    thing that is needed on the internet, someone with a bit of originality!

  23. Louie says:

    Great website. Plenty of useful info here. I’m
    sending it to a few pals ans als sharing iin delicious. And naturally, thanks in your sweat!

  24. Scotty says:

    I think thhe admin off this web site is genuinely working hard in favor of his web page,
    because here every stuff is quality based stuff.

  25. Abe says:

    This is a topic that is near to myy heart…

    Best wishes! Exactly where aare your contact details though?

    1. Webpioneer says:

      Thanks Abe,
      you can reach me on sooraj.bhatt@webpioneer.in

  26. Keep this goig please, great job!

  27. I have read so many articles cooncerning the blogger lovers except thijs paragraph is truly a nice
    post, keep it up.

  28. Jonelle says:

    Very good article. I ccertainly love this website. Keep
    it up!

    1. Webpioneer says:

      Thank you Jonelle

  29. plastik cor says:

    I used to be able to find good information from your content.

  30. Does your website have a contact page? I’m having problems locating
    it but, I’d like to send you an e-mail. I’ve got some suggestions for your blog you might
    be interested in hearing. Either way, great website and I look forward to seeing it expand over time.

    1. Webpioneer says:

      Hello
      Thank you for your feedback.
      you can reach thru form here – https://www.webpioneer.in/contact.html

  31. Rosalind says:

    Excellent post. I was checking continuously this blog and I am impressed!
    Extremely useful information particularly the last part 🙂 I care for such information much.

    I wwas looking for this particular info for a very long time.
    Thank you and good luck.

  32. Vicki says:

    I’ve learn some excellent stuff here. Definitely worth bookmarking for revisiting.

    I surprise how much effort you set to create one off these fantastic
    invormative website.

  33. Margarito says:

    Great article. I’m facing many of these issues as well..

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top