Forum Moderators: phranque

Message Too Old, No Replies

Code for Non-www to WWW

         

Carpy

12:12 pm on Apr 4, 2006 (gmt 0)

10+ Year Member



Ive viewed code pasted by someone on this board.
(sorry didnt get the users name)

Its a 404 redirect from non-www to www.
To to be called from the 404 custom error section with IIS:

--------------
<%@LANGUAGE="VBScript"%>
<%

Dim varFile:varFile = Request.querystring
Dim requestpage:requestpage = replace(varFile,"404;","")
Dim splitFile:splitFile = Split(requestpage,"?")
Dim splitnewFile:splitnewFile = Split(requestpage,":")

Dim newpage
newpage = splitnewfile(2)
If instr(newpage,"/") > 0 then
newpage = mid(newpage,(instr(newpage,"/") + 1))
Else
newpage = ""
End if

response.redirect "http://www.whatever.com/" & newpage
%>
--------------------

Im not a programmer and will only know if it works when I upload it.

However, will this also assign a 301 permanent redirect?
If not, what code should i use.

thanks

physics

3:57 pm on Apr 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




ts a 404 redirect from non-www to www.
To to be called from the 404 custom error section with IIS:

There is no such thing as a 404 redirect. 404 is an error code that your site should return to users/spiders if the page does not exist.
You do want to do a 301 redirect but this should be done at the server level. Follow the instructions in:
IIS 301 redirect [webmasterworld.com]
Or ask your host to set up a 301 PERMANENT redirect from example.com to www.example.com Make sure they don't do a 302. You can check this with the
Server Header Checker [webmasterworld.com]