CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Custom 404.asp + 301 redirect - SOLVED

Print topic Send  topic

Author Message
flipandboef


Posts: 107
Posted: 06/04/2008, 8:02 AM

Hi all,
Hopefully someone can help me here as I'm not an asp guru, however LOVE CodeCharge (using CCS 3.1 / access / ASP)

I'm trying to create a custom 404.asp page that looks if some files have been moved (301-permanent) and redirects it to there, or else shows my 404.asp code..

Example:
- User requests /123.html
- /123.html has become /sub/456.asp
- User is redirected to /sub/456.asp and header responds 301
(letting search engine know it has been moved permanent)

- User requests /abc.html
- /abc.html does not exist
- Header responds 404 and display my original ASP code
(I have a custom 404.asp already in place, therefore like to display the original code if it does responds 404)

Anyone has any ideas on this or (even better) some code that might help me out?

Thanks all!

p.s.: I know it would be much more simple to do this on the server side, but my host (GoDaddy - windows/shared hosting) won't let me change much settings, and they're not willing to help me on this.
View profile  Send private message
flipandboef


Posts: 107
Posted: 06/04/2008, 2:08 PM

For those interested:

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

Is301 = True
SendTo = "/subdir/404.asp"

QS = Trim(Request.ServerVariables("Query_String"))

PathInfo = Right(QS, Len(QS) - Instr(Instr(QS, Trim(Request.ServerVariables("SERVER_NAME"))), QS, "/") + 1)
Select Case PathInfo
Case "/contact.html"
SendTo = "/subdir/Contact.asp"
Case "/news.html"
SendTo = "/subdir/News.asp"
Case Else
If Right(QS, 4) <> ".asp" Then
Is301 = False
End If
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
%>
' write your html OR asp code here
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.