dynamically add www before my domain name url

Posted on 2009-12-29
Last Modified: 2012-05-08
When some one types in I need to dynamically place www. before the domain name if it is not present: Can some one tell me the best way to accomplish this?

Question by:RCairns54
    LVL 11

    Expert Comment

    This is usually something controlled at the web server.... one web server is just setup to take every request, add the www. onto it and then post back, this can be done in a request string....

    Question is do you want to take this much time to do it or just setup your main website with your IP of your server and set an alias for www to your main server, that way both ways will work.

    Personally I would not redirect users but let them have the option of having it or not, both will work...

    Author Comment

    Thanks for your quick reply.

    I have iis set up to handle both the domain and the www subdomain requests, but for seo reasons I need to have the www in the url every time. I have used 301 redirects but this is pretty static and takes you to one base url. I thought about handling the request at the app level, caching the url and adding www to the string and redirect but I was hoping to find a way to do this outside of the web app.

    Here is an example of what I'm looking for:
    If you go to and preform a search and then delete the www. off the url and hit enter it adds it back. This is basically the effect Im looking for.
    LVL 11

    Accepted Solution

    are you using IIS 7?  If so you could use the URL rewriting to redirect non www to www...

    This is from the article and I think is exactly what your looking for:

    For the Action Properties, enter{R:0}.  The {R:0} retains the existing URL so if someone typed something like it would retain the aboutus as it adds the www

    Author Closing Comment

    Sweet. Thanks for pointing me in the right direction.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Title # Comments Views Activity
    DANE and Convergence 6 50
    Automatic Image Uploading 9 50
    New MX Records 12 44
    How to include jquery as a global using webpack 1 36
    Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
    When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40… provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
    Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now