• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

short URL that links to a long URL

Hi,

I have seen sites that use following syntax to link to topic areas:
www.site.com/2366513

Q:
How is that short URL linked if I have a longlink saved in a DB?

I know how to link it using a the response.riderect but that would change the syntax to following:
www.site.com/redirect.asp?link=2366513 -> this NOT how I woant to do it.

Any help is apretiated
thank you
0
LotharGores
Asked:
LotharGores
  • 2
  • 2
  • 2
  • +5
2 Solutions
 
danataylorCommented:
Create a subfolder under wwwroot and name it 2355613.
In that directory create a web page named default.html or index.html or default.asp or index.asp - whatever is configured as the default in IIS.

When you link to www.site.com/2355613 it will load the first default file found.
0
 
LotharGoresAuthor Commented:
Hi,
I thought about that, but that would mean if I had 10000 links that I have to create 10000 subfolders!

is this the only way this would work?
0
 
danataylorCommented:
EEEEWWWW!  Could be.

The only thing else I can think of is if IIS will automatically assume the ".ASP" or ".HTM" extension to a file name.  You could just create a page named 2355613 in wwwroot.  Would require 10000 pages, though and I might just be hallucinating here.  Otherwize you need to pass the 2355613 value as a variable (www.site.com/redirect.asp?link=2366513)

Anyone else have an idea?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Ashley BryantSenior Software EngineerCommented:
Personally, I'd pass the linkID in the string like dana suggested.  There's really no good reason for trying to use the subfolder name to build the link if you have a data driven website.
0
 
SquareHeadCommented:
Yeah, combine those ideas, making "2366513" the value being passed:

www.site.com/?2366513

In other words:

www.site.com/default.asp?2366513
which would be similar to:
www.site.com/default.asp?strMyVariable=2366513

you'd access the querystring value without naming a variable...

strMyVariable = Request.Querystring
0
 
karthikmuthurajanCommented:
Hi
Letz conside 2366513 is a primary key of some table where that table will have primary key and long link.
Now if user access user site, you can get the long url from the primary key they entered in the URL.
You can follow the same logic..

Happy Programming!!!
0
 
AlfaNoMoreCommented:
You can create a custom 404 page. This could something like the following:

404.asp

Dim strURL, _
      arrURI, _
      strRequestedLink, _
      strRedirect
Dim objFSO, _
      objFolder, _
      objDeveloper

strURL = Request.ServerVariables("HTTP_URL")
strURL = Right(strURL, (Len(strURL) - (Instr(strURL, chr(59)))))

arrURI = Split(strURL, "/")

strRequestedLink = arrURI(1)

Response.Redirect("www.site.com/folder/folder/folder/long_page.asp?link=" & strRequestedLink)

You could add some additional checking in there to determine if the 404 is actually beging used in your short-link format, or if it's a genuine page failure...
0
 
deighcCommented:
What you're asking for would often be called 'URL masking'. There are two ways to do this.

- A custom 404 error page (as AlfaNoMore) suggested. This is easy to implement and requires only a small amount of config in IIS.
- An ISAPI filter in IIS. This is definitely the best way (most reliable method, best performance) but requires more fiddling in IIS and you'll probably have to spend money to buy a product to do this. Do a search on Google and see what turns up.
0
 
SquareHeadCommented:
Any update on this?
0
 
deighcCommented:
LotharGores,

Similar question here with some good suggestions:

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21522361.html
0
 
masirofCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Split: AlfaNoMore & deighc

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

masirof
EE Cleanup Volunteer
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now