|
| |
|
|
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
|
|
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
|
|
|