| Another non www to www redirect question
|
flanok

msg:4110608 | 9:38 am on Apr 6, 2010 (gmt 0) | Hi, I am not a coder, but can get away with copying code into the .htacess file with php. But now I have been asked to look after asp site, that is on a shared server. so looking for code to redirect non www to www and index.asp to / for seo reasons. I have found a few posts regarding code and most are the same code or very similar to that below. But I can't get any of these similar examples to work. So my questions are? Do I put this code at the very top of the index.asp file, before the doctype command? If not, then that is probably what I am doing wrong. The code below does not work on this shared server from a well know web host, has anyone had a similar issue and is there something I should do with the hosting? <rule name="Redirect to www" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^example.com$" /> </conditions> <action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" /> </rule> Thanks
|
flanok

msg:4110636 | 10:03 am on Apr 6, 2010 (gmt 0) | Hi Found the solution to redirect non www to www but still having issues with index.asp redirecting to root. Because on our shared server the homepage script is set as index.asp, when ever we redirect to root, it creates a loop back to index.asp over and over again. So the next question, is how to remove this loop, or isthere redirects without loop? Thanks
|
marcel

msg:4110637 | 10:06 am on Apr 6, 2010 (gmt 0) | Hi flanok, The code you have posted belongs in the web.config file, but it will only work with IIS7.x which has the URL Rewrite Module [learn.iis.net] installed. You can ask your host if this is the case. Otherwise you will need a product like ISAPI Rewrite installed on the server.
|
flanok

msg:4110644 | 10:20 am on Apr 6, 2010 (gmt 0) | Hi thanks for the reply the code we have found that works with www but not index.asp is <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then if Request.ServerVariables("URL") = "/index.asp" then say = "" else say = Request.ServerVariables("URL") end if Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www."& Request.ServerVariables("HTTP_HOST")& Request.ServerVariables("REQUEST_URI")& say Response.End End if %> We are wokinging with ii6 It works with www to non www but not the index.asp, which just loops with the www version of the index.asp but works fine with the non www version of index.asp. The problem we have is google has picked up the index.asp within its index and so need a redirect not to have duplicate content issues. Can we install ISAPI Rewrite on a shared server, or is this something that comes with hosting? Thanks mark
|
marcel

msg:4110652 | 10:53 am on Apr 6, 2010 (gmt 0) | The only way I know of redirecting from index.asp to root on IIS6 is to use ISAPI_rewrite (or a tool like it). You will need to ask your host to install this for you, unfortunately many will not do this.
|
flanok

msg:4110653 | 10:55 am on Apr 6, 2010 (gmt 0) | Ok thanks In short, with a shared server you can't redirect index to root
|
marcel

msg:4110702 | 12:22 pm on Apr 6, 2010 (gmt 0) | | In short, with a shared server you can't redirect index to root |
| Well, you can if your host is agreeable to installing extra software, and with IIS7 it's much easier, but in essence most host won't help you here. One option, which is a bit of a hack is to change your default document to something else, say myIndex.asp Rename your Index.asp to this, and create a new Index.asp which redirects to the root.
|
|
|