Forum Moderators: open
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
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
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