The purpose of writing this tip is that somedays before I was almost lost in my current project. It was miserable for me to find out how and where a particular event is fired to execute a particular functionality though it was understandable that the event was fired because whenever I changed something in the event-handler of that particular event the changes were reflecting in the application. Then after a lot of searching and researching I found out a new thing (for me) called “URL Rewriting” as the cause of this happening. Now, lets discuss briefly about the concept “URL Rewriting”.
WHAT IS “URL Rewriting” AND WHY TO USE IT :
The URL Rewriting rule is one the best concept we can use for increasing the searching capability and usability of the developed websites by us in the search engines.
Ex: We have created an application in ColdFusion which contains the product searching feature. So whenever we like to search some product like 'pencil' or anything, a particular ColdFusion service is called or an event is fired to call that service to give us all the data regarding the search resullts of pencil from the database. So, our URL in the web browser for that functionality will be almost like: ( in general ) http://www.productsearch.com/search_product.cfm
Now, from the above URL we cannot get a clear idea about what we are willing to search. And, it is also a littlebit difficult to remember the URL for searching as well as to read out to someone else to use it for searching. Instead of the above URLs if we will use the following URLs in the browser :
Then, from the URL also we can say that we are searching for pencils and its not at all difficult to remember the URL. And also we cannot say by seeing the URL that which technology we have used for the application which is good.
Now, the thing is how our server will know what to process when it gets the request through the last URL of the above so that it can return the user the actual data ( here the results of searching 'pencil' ).
So, the technique of translating the URLs like the above last one internally which the server can understand to process the particular event or service for that functionality ( here the 'pencil' searching ).
HOW TO DO “URL Rewriting” :
To use URL Rewriting we need to first create a file called '.htaccess.txt' or 'rules.htaccess.txt' to contain all the rules to change or translate the URLs and put it under the root folder of the server in our system. If previously the root directory contains this file, then we should edit it instead of overwrite it.