Solved

Request.Servervariables redirect

Posted on 2000-04-14
11
246 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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/…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now