Frienldy URLs
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13266
Printed Date: 30 March 2026 at 4:44pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Frienldy URLs
Posted By: zaboss
Subject: Frienldy URLs
Date Posted: 08 January 2005 at 5:58pm
For an
application I design I need to convert an url like
http://www.mypage.com/an_item to be redirected to an asp page. That is,
if someone is typing the url http://www.mypage.com/an_item, instead of
a 404, to be redirected to
http://www.mypage.com/the_page_Im_actualy_looking_for.as p. I have no
clues what "an item" might be, but it exists and it is grabbed from a
database. The closest analogy is with an online store, where if someone
is typing www.mystore.com/laps it would be redirected to a page like
http://www.mypage.com/item_family.asp?item=lamps, which grabs and
display all the items thar are listed in this category.
------------- Cristian Banu
http://www.soft4web.ro - Soft 4 web
|
Replies:
Posted By: dj air
Date Posted: 08 January 2005 at 6:02pm
you can set redirects from most CP's whos your host.
you can set a redirect (perminant)
|
Posted By: Greyth
Date Posted: 12 January 2005 at 7:56pm
You might try something like this.... Using this, you can do just about anything you want using a 404 page.
URL = Request.ServerVariables("QUERY_STRING")
URLname = Request.ServerVariables("QUERY_STRING")
if instr(1,URL,"404;http://") > 0 then
'Error Page True
ErrorPage = true
URL = replace(replace(URL,"404;http://",""),"_"," ")
if not mid(URL,len(URL)-1) = "/" then
URL = URL + "/"
end if
URLPart = split(URL,"/")
if ubound(URLPart) > 1 then
vdir = lcase(URLPart(1))
end if
end if
IF left(lcase(vdir),5) = "products" THEN
response.status = "200 OK"
productID = replace(vdir, "products", "")
response.redirect("wherever you want to redirect")
'////////////////////////////////////// You could also do a moved permenantly
'Response.Status="301 moved Permanently"
'Response.AddHeader "Location", "http://www.example.com/"
'//////////////////////////////////////
ELSE
%><!--#include file="getTheProductsFromTheDB.asp" --><%
END IF
|
Posted By: zaboss
Date Posted: 13 January 2005 at 1:21am
Very clever solution greyth. Thank you, but it was suggested to me on
another forum and I was working on it. Well, they say that great minds
think alike .
The entire article is http://home.openhosting.co.uk/article.asp?id=28 - here .
------------- Cristian Banu
http://www.soft4web.ro - Soft 4 web
|
|