1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

www and without www

Discussion in 'C#' started by shyren, Mar 5, 2007.

  1. #1
    Hi,
    I am working on a project with ASP .NET 2.0 and some stuff is not working when www is not there in url. How can i set up that it will automatically redirects by appending www in url. Can i do it using web.config
    Thanks
    Salil
     
    shyren, Mar 5, 2007 IP
  2. shyren

    shyren Banned

    Messages:
    158
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <%@ Page Language="C#" AutoEventWireup="true" Debug="true" %>
    <%
    string base=Request.ServerVariables["HTTP_HOST"];
    string url=Request.ServerVariables["URL"];
    base=base.Replace("www.","");
    if(base == Request.ServerVariables["HTTP_HOST"])
    Response.Redirect("http://www."+base+url);
    %>

    I wrote this code for basic redirect. Do you guys think i can do better?
    Thanks
     
    shyren, Mar 5, 2007 IP
  3. Truman

    Truman Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Has anybody seen a website with 6 'w' in the beggining ? That's not a joke,it exists !
     
    Truman, Mar 5, 2007 IP
  4. cumminsj

    cumminsj Guest

    Messages:
    225
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Huh, you can have what ever you want at the beginning of a domain !!:confused:
     
    cumminsj, Mar 13, 2007 IP
  5. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #5
    lol, www is just a sub-domain. you can have wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww.domain.com if you wanted :)
     
    ccoonen, Mar 15, 2007 IP