Link to home
Start Free TrialLog in
Avatar of webmatt
webmatt

asked on

Request.Servervariables redirect

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

Avatar of jkunal
jkunal
Flag of India image

You can write an ISAPI filter for this.

(OnUrlMap)

find out the number and redirect it to the related page.
Avatar of webmatt
webmatt

ASKER

How complicated is that.  I haven't done it before.

Avatar of webmatt

ASKER

How complicated is that.  I haven't done it before.

Avatar of Paul Maker
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

Avatar of webmatt

ASKER

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
dont use an id then use a filename instead or some other meaning full word for each file
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
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.
ASKER CERTIFIED SOLUTION
Avatar of ozymandias
ozymandias
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webmatt

ASKER

This works great!

thanks
No problem.