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.

i have .asp pages im looking to put my non www to my www with a web.config file

Discussion in 'C#' started by computergeeks, Jun 5, 2012.

  1. #1
    hi i host at godaddy and im on a windows server! i want my url to point to my www url and not my nonewww for seo rezones. here is my problem godaddy told me
    to make a web.config file so i did..

    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <configuration>
    <system.web>

    </system.web>
    </configuration>

    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name=”Redirect to WWW” stopProcessing=”true”>
    <match url=”.*” />
    <conditions>
    <add input=”{HTTP_HOST}” pattern=”^domain.com$” />
    </conditions>
    <action type=”Redirect” url=”http://www.mydomainname.com/{R:0}”
    redirectType=”Permanent” />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>


    SEMrush
    but i think i did it wrong! i uploaded it in my main dir and named it web.config but its giving my a 500 page error!
    http://www.mydomainname.com/ i changed this to my domain name..


    can someone help my with this ? ps i cannot get off a windows server i have a 500 page site all .asp and not.html
     
    computergeeks, Jun 5, 2012 IP
    SEMrush
  2. jaypeegreens

    jaypeegreens Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nice
    your code is right and i hope it will work properly.
    Cheers!
     
    jaypeegreens, Jun 11, 2012 IP
  3. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #3
    my code is right? himm its not working! does this take time to work? as soon as you upload it should the code work?
     
    computergeeks, Jun 11, 2012 IP
  4. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #4
    when i upload that this is what i get..
    500 - Internal server error.
    There is a problem with the resource you are looking for, and it cannot be displayed.
     
    computergeeks, Jun 11, 2012 IP
  5. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #5
    i also spent some time on the phone with my host and they said they have re-wright setting turned on! im really stuck!
     
    computergeeks, Jun 11, 2012 IP
  6. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #6
    I need help!
     
    computergeeks, Jun 14, 2012 IP
  7. rocky533

    rocky533 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I host at godaddy too. I do the same thing your asking but i dont use the web.config.
    I use an asp include on every page at the top (first code on page) However i go from the www version to the non.

    My Code
    <%
    If InStr(Request.ServerVariables("SERVER_NAME"),"www") Then
    Response.Status="301 Moved Permanently"
    strAddress = replace(Request.ServerVariables("HTTP_HOST"),"www.","")
    QueryString = Request.ServerVariables("QUERY_STRING")
    if QueryString <> "" Then QueryString = "?" & QueryString end if
    Response.AddHeader "Location","http://" & strAddress & Request.ServerVariables("URL") & QueryString
    Response.End
    End if
    %>

    For you (not tested may need tweeking)
    <%
    If not InStr(Request.ServerVariables("SERVER_NAME"),"www") Then
    Response.Status="301 Moved Permanently"
    strAddress = "www." & Request.ServerVariables("HTTP_HOST")
    QueryString = Request.ServerVariables("QUERY_STRING")
    if QueryString <> "" Then QueryString = "?" & QueryString end if
    Response.AddHeader "Location","http://" & strAddress & Request.ServerVariables("URL") & QueryString
    Response.End
    End if
    %>


    Put this in a file an include in on every page there is at the very top.

    Also i recommend going to google and bing webmaster tools and change the domain to the one you choose.
     
    rocky533, Jun 15, 2012 IP
  8. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #8
    rocky thanks a ton!
    the only thing is i have 500 pages! himmm there is no way to get the web.config file working?

    if no thats ok i can still use this code i would just have to drop it on 500 pages might take a few days to do..

    thanks for your help
     
    computergeeks, Jun 18, 2012 IP
  9. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #9
    rocky why do you use the none www and why not the www? i here that the www is a better way to go! but i could be wrong just wondering
     
    computergeeks, Jun 18, 2012 IP
  10. rocky533

    rocky533 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I hate typing www. Its just an extra sub domain. I am assuming most people would do the same in the future once they all realize that www means nothing. i am not sure what others think.

    I am sure you can use web config, i have just never done so. I Just pick an include on the top of the page (eg header) and put the redirect at the top of that include. Hopefully you use server side includes, if not you will have to add the code to all pages. The code doesnt have to be the very top, just as close as you can so it doesnt have to load to much code 2 times. (at most the HTML HEAD)

    Hope this helps.

    Edit - also if you use a global database connection include at the top of pages you can include the script in there.
     
    rocky533, Jun 18, 2012 IP
  11. computergeeks

    computergeeks Active Member

    Messages:
    341
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #11
    thanks for the help!
     
    computergeeks, Jun 19, 2012 IP