Forum Moderators: open

Message Too Old, No Replies

Using 404's to URL Rewrite.

Can this be done? Can I disable the 404 header

         

chris_f

2:07 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Gals and Guys,

I am thinking of a clever way to URL rewrite via shared hosting. As it's shared hosting I can't install any components to URL rewrite. I was thinking of customising the 404 page so that it reads the page that was attempted to be accessed and uses server.transfer to display the correct page.

e.g. www.widget.com/advert/10.asp

will be altered to

www.widget.com/advert.asp?id=10

The only issue I can find is that the 404 header is returned and as such the spiders will think that the page is not being used and 'Page Not Found' appears in the title.

Does anyone know how to stop it returning the 404 header?
Chris

jimbo_mac

2:21 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



chris_f

try out *http://www.xav.com/scripts/guardian/

chris_f

4:18 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jimbo_Mac,

However, that in Perl based. I am using ASP and it's shared hosting and as such I can't install anything.

Chris

Gibble

4:20 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know someone who did this in ASP, sticky me your email address and I'll try and have him email you :)

chris_f

4:27 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Gibble,

I've stickied you. As I said, I can code the actual page. The only problem I have is removing the 404 header so the spiders don't know it's a 404.

Chris

Dreamquick

4:31 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In ASP if you have everything working apart from the page returning the wrong status code then the code you need is;

Response.Status = "200 OK"

Which would set the status code to 200 with the text portion reading "OK" - it shouldn't be rocket science to see where the status code goes if you want something other than 200!

Should you find yourself being redirected by IIS to your custom error page (thus spoiling your neat masking technique) you need to ensure that the IIS configuration for the ASP extension has the "check file exists" flag enabled.

- Tony

chris_f

4:44 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tony,

Are you saying rather than use a 404 to cover my dynamic pages I should use a 200? The problem with that is the actual URL called will not exist on the server. That is why I was thinking of using the 404.

The URL linked to will be:

www.widget.com/advert/10.asp (the advert directory will not exist)

this will cause a 404. The 404 will read the path and see the advert directory. It will rewrite the URL to a valid path like:

www.widget.com/advert.asp?id=10

I will then server.transfer to this url so as not to let the browser know about the redirect.

This will be URL Rewritting on shared hosting and with no components. The only problem is the page will still return a 404 and as such the search engines will not list it and the primary reason I am doing this is so the search engines (other than Google) can read the dynamic pages.

Many Thanks
Chris