Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL dilemma 2

Status
Not open for further replies.

ncar35b

Technical User
Jan 10, 2003
55
US
Hi! I need to create about 300 unique subdirectories on a website that will redirect to specific doctor websites. For example:

(this would redirect to a unique site)
(this would redirect to a unique site)
(this would redirect to a unique site)

Does anyone have a way I could create something server side in ASP to possibly parse the URL and maybe hit a database that says '/drsmith redirects to I'd like to avoid hardcoding 300 directories and 300 redirect files. I really just need someone to point me in the right direction. Thanks for your thoughts!!

NOTE: I have no freedom to change that URL structure, unfortunately.
 
A custom 404 page will do the trick. Don't create any of the directories, and on your custom 404 page simply examine the Request.Servervariables("PATH_INFO") to determine what information to serve on your redirect, adding the "directory" to the querystring. If there's no match simply serve the 404.
 
(Sorry, to clarify, you don't need to redirect, you can just serve the info if you want to.)
 
that's a fantastic idea, didn't think of that!! Thanks Genimuse!
 
Genimuse:
situation: Online
in this case will the Service Provider allow me to change the custome_404 page? even if i change wont it affect other sites hosted on the web???

Known is handfull, Unknown is worldfull
 
as long as there is a unique instance of a web server set up for each site hosted, you can have a custom 404 page without affecting other sites hosted.
 
ur statement seems to have a condition, generally how is it???

Known is handfull, Unknown is worldfull
 
vbkris, I'm not sure I understand what you mean.

Also, I have a new dilemma. The Request.Servervariables("PATH_INFO") just gives me the location of the 404 error page, not the refering page. And when I try HTTP_REFERER, the server isn't showing me the refering URL (the string is empty). Any thoughts?
 
Have you checked the querystring of the 404 page? You should have something like this...
Code:
[URL unfurl="true"]http://www.spiraxsarco.com/include/error.asp?404;[/URL][b][URL unfurl="true"]http://www.spiraxsarco.com/dsadsa.asp[/URL][/b]
You should be able some simple string manipulation to extract the page request that caused the 404

Tony
________________________________________________________________________________
 
Thanks Tony, if I just do a generic request.querystring, I can get the referer and parse that URL!
 
Oops, sorry, forgot you need to get it out of the querystring. I haven't set one of these up in a while. Glad it's working.

This is some code I wrote once to pull out potential keywords... in my case it was so that people could type " to get to the munchkins page. I wrote it quite a while ago, so it might be inefficient. Might be sweet, too. :)
Code:
Dim Path
Path = Request.ServerVariables("QUERY_STRING")
Dim oRegExp
Set oRegExp = New RegExp
oRegExp.Global = False
oRegExp.Pattern = "^[^/]+//[^/]+"
Path = oRegExp.Replace(Path, "")
Set oRegExp = Nothing
If InStr(1, Path, "/") > 0 Then
	If InStr(2, Path, "/") > 0 Then
		Path = Right(Path, Len(Path) - 1)
		Path = Left(Path, InStr(1, Path, "/") - 1)
	Else
		Path = Right(Path, Len(Path) - 1)
	End If
End If
Then the variable "Path" contained the potential "keyword," and I checked the db for a match.

Glad to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top