Print Page | Close Window

Redirecting pages + 404 - FYI

Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Customizing ProductCart
Forum Description: Exchange messages with other users that are customizing ProductCart.
URL: https://forum.productcart.com/forum_posts.asp?TID=1684
Printed Date: 20-May-2024 at 11:54am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Redirecting pages + 404 - FYI
Posted By: worldofrugs
Subject: Redirecting pages + 404 - FYI
Date Posted: 03-June-2008 at 10:00am
For those interested:
I created some code to have old pages redirect to the new ones, including a custom 404 error page...
It will give nicely the status 301 (and 200) or 404 for the Search Engines...

So here's the code for all who like to use it:

<%@  language="VBScript" %>
<%
Dim Is301
Dim ResponseStatus
Dim SendTo
Dim QS
Dim PathInfo

Is301 = True
SendTo = "/productcart/pc/404.asp

QS = Trim("" & Request.ServerVariables("Query_String"))
If QS <> "" Then
PathInfo = Right(QS, Len(QS) - Instr(Instr(QS, Trim(Request.ServerVariables("SERVER_NAME"))), QS, "/") + 1)
Select Case LCase(PathInfo)
    Case "/contact.html"
             SendTo = "/productcart/pc/Contact.asp"
     Case "/news.html"
            SendTo = "/productcart/pc/News.asp"
    Case Else
                Is301 = False
End Select

If Is301 Then
    Response.Status =  "301 Moved Permanently"
    Response.AddHeader "Location", "http://" & Trim(Request.ServerVariables("SERVER_NAME")) & SendTo
Else
    Response.Clear
    Response.Status =  "404 Not Found"
End If
End If
%>
' write your html OR asp code here




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net