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> 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
my code is right? himm its not working! does this take time to work? as soon as you upload it should the code work?
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.
i also spent some time on the phone with my host and they said they have re-wright setting turned on! im really stuck!
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.
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
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
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.