navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Free FrontPage Templates

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Custom 404.asp + 301 redirect - RESOLVED

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> General Web Development >> Custom 404.asp + 301 redirect - RESOLVED
Page: [1]
 
worldofrugs

 

Posts: 4
Joined: 5/1/2008
Status: offline

 
Custom 404.asp + 301 redirect - RESOLVED - 6/4/2008 11:13:24   
Hi all,
Hopefully someone can help me here as I'm not an asp guru :)

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 doe 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, not are they willing to help me on this.

< Message edited by worldofrugs -- 6/4/2008 17:08:55 >
worldofrugs

 

Posts: 4
Joined: 5/1/2008
Status: offline

 
RE: Custom 404.asp + 301 redirect - RESOLVED - 6/4/2008 17:09:30   
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

(in reply to worldofrugs)
Page:   [1]

All Forums >> Web Development >> General Web Development >> Custom 404.asp + 301 redirect - RESOLVED
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts