Discuss URL Rewrite using ASP in the Code Bank forum on ASP Free. URL Rewrite using ASP Code Bank forum containing sample code and scripts to help solve common problems. Take a look and use the code to assist in your projects.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.
Posts: 4
Time spent in forums: 1 h 39 m 12 sec
Reputation Power: 0
URL Rewrite using ASP
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
Your main pages passing values to the product page must point to the url you and the SEs want the user to see on the browser, like yourdomain/prod_13.html as opposed to yourdomain/products.asp?productID=13
IIS will recognize that this file (Product_13)or folder does not exist and will redirect you to a 404 page, that you have created (make sure to create a asp page like 'rewrite.asp' and set it up as your custom error page on your server host pointing to '/rewrite.asp')
On the 404 error page, you will take the Request.ServerVariables("QUERY_STRING") coming from the previouse page (which is the non existing URL: domainname/prod_13.html), you will clean the code using replace() and use your number 13 to store it on a session variable or a cookie (this is just an example)
And Then you can do the server.transfer to the product.asp page (with no querystring containing ? or & or = because server.transfer does not support that)
On the Products.asp page, then you can read the session variables or cookies and then do your query to return the product.
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):
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
Posts: 6,191
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 134
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.
Posts: 4
Time spent in forums: 1 h 39 m 12 sec
Reputation Power: 0
Quote:
Originally Posted by degsy
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.
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.
Posts: 5
Time spent in forums: 1 h 8 m 55 sec
Reputation Power: 0
Quote:
Originally Posted by udelojf
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
Your main pages passing values to the product page must point to the url you and the SEs want the user to see on the browser, like yourdomain/prod_13.html as opposed to yourdomain/products.asp?productID=13
IIS will recognize that this file (Product_13)or folder does not exist and will redirect you to a 404 page, that you have created (make sure to create a asp page like 'rewrite.asp' and set it up as your custom error page on your server host pointing to '/rewrite.asp')
On the 404 error page, you will take the Request.ServerVariables("QUERY_STRING") coming from the previouse page (which is the non existing URL: domainname/prod_13.html), you will clean the code using replace() and use your number 13 to store it on a session variable or a cookie (this is just an example)
And Then you can do the server.transfer to the product.asp page (with no querystring containing ? or & or = because server.transfer does not support that)
On the Products.asp page, then you can read the session variables or cookies and then do your query to return the product.
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):
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
Hello can't get this working for my URL : http://immobiliareitalia.net/comune.asp?id=1703
Could you past me please the code that will work in my case?
Thank you