Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 6th, 2007, 03:33 PM
udelojf udelojf is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 4 udelojf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 m 12 sec
Reputation Power: 0
Wink 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):

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

Reply With Quote
  #2  
Old March 7th, 2007, 09:41 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
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

Reply With Quote
  #3  
Old March 7th, 2007, 11:17 AM
udelojf udelojf is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 4 udelojf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Jovanky

Reply With Quote
  #4  
Old March 30th, 2007, 11:53 PM
baseballdude_'s Avatar
baseballdude_ baseballdude_ is offline
Expert Learner
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2005
Location: Wisconsin
Posts: 1,878 baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)baseballdude_ User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 22104 Folding Title: Starter FolderFolding Points: 22104 Folding Title: Starter Folder
Time spent in forums: 1 Week 5 Days 11 h 55 m 55 sec
Reputation Power: 62
Send a message via AIM to baseballdude_ Send a message via MSN to baseballdude_ Send a message via Yahoo to baseballdude_ Send a message via Google Talk to baseballdude_
To solve the 404 error issue with search engines, use Response.Status = "200 OK" to change the status back to ok.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > URL Rewrite using ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT