404 Redirect Question

D

DanTg

Hi all,

I want to build a custom 404 error page that using asp will
dynalically build the page.

Here is my problem. I am building a directoy website which has over
3000 categories. I do not want to create a category page for each one
so I though I would try and cheat a little and use the 404 to make it
look as if the page exists and put out the relevant information.

The website is:
http://www.pricerequest.co.uk/

The page I am linking to (which does not really exist) is:
http://www.pricerequest.co.uk/a/Cars_Motorbikes.html

The page you see when you go to
http://www.pricerequest.co.uk/a/Cars_Motorbikes.html is actually the
404 page.

So what I want it to do is the 404 page ASP code will look at the page
name 'Cars_Motorbikes' search the categories database table and pull
out the category information.

So in IIS I tried setting the Custom Errors 404 Message Type as File
but IIS does not or I can't get this page to process it as ASP to then
dynamically build the page.

The 2nd thing I tried was setting the Message Type as URL. This works
but the URL string looks like:

http://www.pricerequest.co.uk/a/cat...www.pricerequest.co.uk/a/Cars_Motorbikes.html

When really I want the URL to look like:

http://www.pricerequest.co.uk/a/Cars_Motorbikes.html

Does any one know how I can do this in IIS? Is there any external
filters, executables that can make IIS do this?

Thanks,

Dan Chapman
 
J

Jeff Cochran

Hi all,

I want to build a custom 404 error page that using asp will
dynalically build the page.

Here is my problem. I am building a directoy website which has over
3000 categories. I do not want to create a category page for each one
so I though I would try and cheat a little and use the 404 to make it
look as if the page exists and put out the relevant information.

The website is:
http://www.pricerequest.co.uk/

The page I am linking to (which does not really exist) is:
http://www.pricerequest.co.uk/a/Cars_Motorbikes.html

The page you see when you go to
http://www.pricerequest.co.uk/a/Cars_Motorbikes.html is actually the
404 page.

So what I want it to do is the 404 page ASP code will look at the page
name 'Cars_Motorbikes' search the categories database table and pull
out the category information.

So in IIS I tried setting the Custom Errors 404 Message Type as File
but IIS does not or I can't get this page to process it as ASP to then
dynamically build the page.

The 2nd thing I tried was setting the Message Type as URL. This works
but the URL string looks like:

http://www.pricerequest.co.uk/a/cat...www.pricerequest.co.uk/a/Cars_Motorbikes.html

When really I want the URL to look like:

http://www.pricerequest.co.uk/a/Cars_Motorbikes.html

Does any one know how I can do this in IIS?

You can't. It's a 404 page, not the page you intend it to be.
Is there any external
filters, executables that can make IIS do this?

I wouldn't think so, but maybe if you don't use ASP. ASP has to be a
URL because it needs to be processed by the server, but a file could
probably be created to do something similar to what you ask.

Jeff
 
M

Mauricio Freitas [MVP]

I actually do this in one of my sites... Someone enters
http://www.mywedding.co.nz/<username> and the 404.asp script will looking
the database for <username>. If it exists there's a response.reditect to a
pageload.asp that will build the page and return it, otherwise the 404.asp
shows a "Not found" message.

I just scan the querystring:

on error resume next
strRequest = Request.QueryString
strAbsUrl = LCase(Mid(strRequest, Instr(Instr(1, strRequest, "://") + 3,
strRequest, "/")))
strAbsUrl = right(strAbsUrl,len(strAbsUrl) - 1)
on error goto 0

strAbsUrl will contain the bits after .com/...


--
Mauricio Freitas, Microsoft MVP Mobile Devices
Bluetooth guides: http://www.geekzone.co.nz/content.asp?contentid=449
Geekzone Software Store: http://www.geekzone.co.nz/store
Our RSS feeds give you up to date information on new software as soon as
they're available: http://www.geekzone.co.nz/content.asp?contentid=3344
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top