Nowadays, without SEO (Search Engine Optimization), there is chance that a website may not get indexed by search spiders or crawlers. Thus, if website is not ranked high enough it will result in poor conversion rate.
Two main advantages of rewriting URLs are:
1. Search Engine Optimization:
Search engines are much more at ease with URLs that don’t contain long query strings. It becomes easy for the search engine to rank the page URL higher this way.
Consider the Dynamic URl below:
This type of link can cause the search engine to miss the main contents in the URL in terms of SEO and thus prevent the page from getting the desired rankings. After rewriting, the URL becomes easier to understand and there are many chances of it to get ranked.
The URL is rewritten as:
With optimized URLs, it becomes easy for the search engines to distinguish folder names and to establish real links to keywords. These can be indexed easily.
2. Increase in usability for web users and in maintainability for webmasters:
A web surfer will find it tough to remember a URL full of parameters, also he would be discouraged by the idea of typing each parameter at a time. Also, there is a possibility of mistyping which would lead to an undesired page. In case of webmaster it is easier for him to maintain records of the clean or optimized URL than that of dynamic URL.
Some Steps to be considered while Rewriting URLs :
- 1. Keep the URL short and tidy
Make the site directories and file names short but meaningful. For example /products is better than /p. Find the shortest identifiers that include a general description of the page contents or function.
- 2. Avoid punctuation marks in file names
Often designers use names like product_spec_sheet.html or product-spec-sheet.html. The use of underscore is sign of a carelessly designed site structure.
Note: The usage of underscore in the file naming structures is not user friendly. We recommend separation of file names using hyphens (-).
- 3. Use lower cases
Use of upper and lower case in URL is troublesome because depending on the web server’s operating system, file names and directories may or may not be case sensitive. For example, http://ww.xyz.com/Products.html and http://www.xyz.com/products.html are two different files on a UNIX system but the same file on a Windows system.
- 4. Add easy to guess entry points in URL
Since users guess domain names, it is easy for users – particularly power users – to guess directory paths in URLs.
For example, a user trying to find information about Microsoft Word might type ‘http://www.microsoft.com/word ’ .
Many sites have already begun to create a variety of synonym URLs for sections. For example, to access the careers section of the site, the canonical URL might be http://www.xyz.com/careers. However, adding in URLs like http://www.xyz.com/career, http://www.xyz.com/jobs, or http://www.xyz.com/hr is easy and vastly improves the chances that the user will hit the target.
- 5. Avoid exposing technology via directory names
Uses of names associated with server side technology disclose implementation details and discourage permanent URLs. Generalized paths should be used in case of this scenario. For example, instead of /cgi-bin, use a /scripts directory.
Tutorial for rewriting the URLs with the help of PHP, mod rewrite and .htaccess in Apache:
To turn on the module use mod_rewrite in first line in htaccess using the code below:
RewriteRule ^page/([0-9]).html$ /page.php?id=$1
For example: page/([0-9]).html$ will be redirected to /page.php?id=$1
([0-9]).html$ call the number value which is ID in URL.
We can call multiple numbers on this rule as mentioned below:
RewriteRule ^page/([0-9])/([0-9]).html$ /page.php?id=$1&pagenum=$2
We get the two variables:
We can call these variables and show the actual page results.