Solved

Request.Servervariables redirect

Posted on 2000-04-14
11
259 Views
Last Modified: 2006-11-17
I want to give each item in my Db it's own "static" page. I will do that by capturing the id and passing the id number to a search page.  I want to see if it is possible to pull the item number directly from the url without having to include a .asp file in the url.  

Example:

www.somerandomsite.com/123456  which i would pull the number 123456. and redirect to the search page.

i can do this with www.somerandomsite.com/default.asp?123456 but am trying to keep the url as short as possible and allow any user to be able to remember what to enter without having to type in all that information.

Is there a way i can force all request for that directory to go to the default.asp page and then pull the last digits off, again without making the user type in default.asp.


Thanks in advance

0
Comment
Question by:webmatt
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 4

Expert Comment

by:jkunal
ID: 2715782
You can write an ISAPI filter for this.

(OnUrlMap)

find out the number and redirect it to the related page.
0
 

Author Comment

by:webmatt
ID: 2715869
How complicated is that.  I haven't done it before.

0
 

Author Comment

by:webmatt
ID: 2715886
How complicated is that.  I haven't done it before.

0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 10

Expert Comment

by:makerp
ID: 2715928
very :)

just write a default.asp that takes a querysting parameter say called page id then in the default.asp take the id get the page and then do a response.redirect. you could even store the page in the db and just print it to the user..

i.e

default.asp

pageid = Request("pageid")
Set con = Server.createobject("ADODB.Connection")
con.Open your dsn
Set rs = con.Execute("SELECT * FROM pages WHERE page_id = "pageid)

THEN EITHER

response.redirect(rs("filename"))

OR

response.write(rs("contents"))

filename will be the name of the file and it will be held in the db or you could hold the whole contents and use response.write to put it out.
the contensts will have to be a memeo field

0
 

Author Comment

by:webmatt
ID: 2716142
makerp

this will work but i cant advertise every item as www.somerandomsite.com/default.asp?id=12345.

it just isn't memorable and the average consumer wont remember it.  which is why i'll have to check out isapi unless someone has another suggestion.

thanks
0
 
LVL 10

Expert Comment

by:makerp
ID: 2716161
dont use an id then use a filename instead or some other meaning full word for each file
0
 
LVL 10

Expert Comment

by:makerp
ID: 2716200
even if you use an isapi you will still have to pass it some kind of identifier so it can detaermine the page to display...

writting an isapi will be a serious over kill here
0
 

Expert Comment

by:ssoni
ID: 2717358
Maybe this helps. But youwill have to do a bit of digging. In Apache there is an option called MultiViews or the Alias option.

For example if you have MultiViews turned on and you have a file called
abc.cgi in your document root, (or if /abc is Aliased to abc.cgi)
then requesting:
    http://my.domain.com/abc/foo
.... would run abc.cgi with the PATH_INFO server-variable set to 'foo'.

So if you query for SERVERVARIABLES "PATH_INFO" u will get 'foo'.

Check out if your web server supports aliases and then u should be able to do what u want.

Soni.
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 100 total points
ID: 2718724
You can set up custom error responses.
For instance, if you request :

http://www.somesite/dir/page.asp and the page is not there you get a 404 error and an error page is displayed.

You could configure your server to display http://www.somesite/dir/default.asp whenever a 404 ocurrs in that directory.

Then you use default .asp to query the headers and display the real page either by redirecting or by pulling it into a full-size frame within default.asp.
0
 

Author Comment

by:webmatt
ID: 2777876
This works great!

thanks
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 2778559
No problem.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP Classic - Load test 2 53
Using querystring in a hyperlink 3 56
Classic ASP application Will support SQL 2014 5 94
Diminish Pop-up  in 3 seconds 7 49
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question