| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
There was a great posting on this forum, which gave everyone code suggestions to achieve what ASAPI Writer does for ASP websites, but without the need to install software on IIS. As you all know, shared hosting is very economical so no one wants to go on dedicated if they can implement code to achieve the rewrite by physically installing a rewrite application like ASPAPI Rewrite.
The rewrite will accomplish that non friendly URLs like these domain/products.asp?ProdID=13 Look more like this domain/product_13.html This achieves more friendliness for SE inclusion and also a friendlier text for users to type (although I dont see why anyone would type this). In sinthesis, the forum provided great information by recommending to create a dedicated 404 page and paste some server.transfer code in order to accomplish the task. What was missing there was How do you trigger the 404
I kind of got confused with my own explaination there and I hope you understand it. The url code I used on the 'Product page' goes as follows (to produce the 404 and at the same time transfer the ID number to the error page): Code:
SubCats = SubCats & "<LI><font face=verdana size=1><b><a href='"&Replace(RS("Category_name")," ","-")&"_"&RS("Category_id")&".html'>"&Rs("Category_Name")&"</a></font>"
This is a sample code to clean the URL and obtain the ID numbers, store them and then redirect using server.transfer assuming you know how to clean up and obtain partial information off the text string (or querystring) Error page code: Code:
<%
Dim strRefer
'getting the querystring from the server '
strRefer = lcase(Request.ServerVariables("QUERY_STRING"))
'cleaning up the server information carried out with the domain (print with response.write to see the exact response)
strRefer = replace(strRefer,"404;domain/:80", "")
strRefer = replace(strRefer,"/","/products.asp")
'splitting the remaining string (domain/product_13.html) to get the info past "_". that will return 13.html
CatNumber = split (strRefer,"_")
'Taking the "html" extension off to get the number independently from the string, that will return 13
CatNumber(1) = replace(CatNumber(1),".html","")
'storing the id number on cookie (13 in this case)
response.cookies("CatNumber") = CatNumber(1)
response.cookies("CatName") = CatName
'doing the server.transfer to call listings.asp without change the URL on the browser, read more about server.transfer if you need to, just google it
Server.Transfer("Listings.asp")
%>
I hope this helps, I can't answer all your questions and I am sure some other GURU is going to suggest a better way, but that is just it. Just trying to help out and clarify the confusion. By the way, you can submit to my free directory any time - it is 9searches.org Jovanky |
|
#2
|
|||
|
|||
|
There are two main problems with this method.
1) Error pages are there for a reason. They are there to tell you when your site is not working correctly. You may just have standard error pages, but you may also want custom error pages that tell you and the user what went wrong. Also, if you have logs enabled then all of these 404 errors will be being stored in your logs. How do you then work out which are genuine and which are redirects? 2) Some search engines will drop your pages if they keep getting 404 headers back from the pages.
__________________
CyberTechHelp |
|
#3
|
|||
|
|||
|
Quote:
1-Search engines cannot identify this as a 404, that has been proven 2-404 errors tell you when your resource is not found, and generally, that goes to the default page if it is not customized. This method will handle any other error as a regular default 404 page. The code presented here is just a portion of what your 404 will be, further code should be applied to differentiate and return custom output (out of the scope of my post though) 3-You are right about the logs. Logs are specific in terms of the resource you are requesting and was not found. If you are the developer of this application, you will be able to tell what is an error and what is a redirect. I think is worth a try, given you wont have to pay 50 dollars for dedicated hosting and will accomplish the same. But that is a preference thing. My post was to help people understand how to trigger th 404 since other posts did not explain this on the same topic. Jovanky |
|
#4
|
||||
|
||||
|
To solve the 404 error issue with search engines, use Response.Status = "200 OK" to change the status back to ok.
__________________
www.xoise.com - www.ourfreegames.com - www.playtouchgames.com - www.randomtools.net - www.xenocide-rpg.com |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > URL Rewrite using ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|