URL Rewriting

What is URL Rewriting?

A website "www.monsite.com" hosted by a Web server has a root folder. This root folder is a file like all the ones you see on your computer.

By default, when a browser (Firefox, Internet Explorer ...) requests from a Web server the content of the URL "http://www.mysite.com/folder1/file1.html", the server looks if there is a file called "file1.html" inside the sub-folder "folder1". If this file is found, the content of the file is returned to the browser.

This basic explanation therefore establishes a direct link between a URL and the path of a traditional computer file

In reality, the Web servers pass through a supplementary step that enables them to separate (decorrelate) the URL seen by the visitor and the physical path of the correspondent resource. This additional step is called URL Rewriting

Therefore, the URL Rewriting is a set of rules created by the webmaster in order to transform input URLs into different ones.

For example, you can rewrite "http://www.mynsite.com/beautiful-url/" as "http://www.mysite.com/folder1/file1.html"

Unlike redirects, URL Rewriting is completely transparent to the user because the URL of the browser does not change before his eyes (/beautiful-url/).

Do you need to do URL rewriting on your website?

URL Rewriting has at least 3 advantages

  • it allows you to display to users simple URLs. Long and intricate URLs divert the user's attention and give him the impression that the website is too complex.
  • enables Webmasters to technically change the hierarchy of the website, while still preserving the existing URL's of the website (it is essential that the URL's of a website are static, in order to support SEO).
  • this gives the SEO specialist more control over the keywords that appear in the URLs regardless of technical considerations. The keyword URLs appear to play a role in a page's ranking in Google.

However, it should be noted that the URL Rewriting is a fairly sophisticated technique that requires some computer skills. More specifically, you must master the use of regular expressions. It is always possible to copy/paste examples found on the internet but you still have to test everything and debugging is not always easy (it usually works through log files).

How to rewrite URLs

The first thing you need to do when implementing URL Rewriting is to install a rewrite engine on your Web server (if one is not already installed). For example:

  • If you have an Apache server then instal the "mod_rewrite" module. You will write the set of rules in the configuration file of Apache or in the .htaccess file.
  • If you have an IIS, you must use an extension called "URL Rewrite" (there are others available too)

Once your engine is installed, you must write the URLs rewrite rules. Then put them in the global configuration file of the website or in sub-folders (.htaccess). This Yakaferci article does not provide in-depth details. For more information, consult the official documentation of the module or search for tutorials on the Internet.

If you want to learn more...

Other articles from Yakaferci's SEO category can also be helpful.