..


Sponsored Links

Practical Guide to the module in Apache Rewrite

Article written by Claudio Garau
Page 1 of 4

1. Introduction to Apache mod_rewrite

The mod_rewrite Apache modules is one of the most widely used among those available for this Web server, in particular the fact of making available a tool that allows Webmasters to be a part of creating Web sites based on dynamic web based applications and on the other make the pages produced by the application "digestible" for the search engines.

But what is the function of this module? In practice the mod_rewrite allows you to "translate" a URL in another user-defined according to certain rules which must be written within the Apache configuration file or inside a separate file, called. Htaccess file, which will be uploaded to 'inside of the root of our web site (even the' upload this file must be conducted according to certain criteria, but will deepen this discussion in a moment).

A classic case of use of mod_rewrite is related to the translation of URLs into static dynamics, mind you that this concept is crucial, because the form is not meant to make dynamic address (containing querystring) as static, but rather the opposite! The search engine and our users will see a static URL (pippo.html), but in reality the resource exists in a dynamic address (pagina.php? Id = foo).

To do this we will write our rule in the translation. Htaccess file and upload it to the desired location (ie one for which the rewrite rules apply), and from that moment on, the pages involved the following steps will occur for our Web Server:

  • require clients to access a particular resource by typing a URL into the address bar of your browser (in our case pippo.html);
  • Web server (Apache, of course), receive input and check if the specified path is valid for the requested resource;
  • pippo.html page does not exist, then the request in principle should not be satisfied;
  • but then the Web server will look for instructions on what to do and find the file. htaccess;
  • including the rules specified in the file, the Web server translates the address you typed in the real world and will return the desired resource.
Reading the passages of the judicial process of "translation" of the URL, it would be possible to confuse this form with other available such as the Apache to redirect, rewrite, however, we are not with redirecting the path of a request to a resource but "masking" the same path, then the URL used by the client actually is not a valid path within the server and might not ever be, something that happens in the case of redirects.

But why hide a URL? Nowadays the reasons must be sought in factors that often do not relate to matters closely related technical or application development.

Initially the mod_rewrite was created to address the problem of the URL is too long to type, it happened (and often still happens) that to achieve detrminata resource type were overflowing with querystring variables and parameters; rewrite eliminates this problem by the ability of clients to provide more user friendly URL.

Today, instead of rewriting has become a very important topic for operations with the positioning of websites in search engines.
And 'well known fact that they do not index pages efficiently reached by querystring too long or too rich in parameters, this factor may limit the ability of the placement of a resource within the SERPs.
In practice we can say that what is user friendly for users it is for search engines.

In the same category ...
E-Learning
Linux (Course) Linux (Course)
Complete guide to open-source system. From 49 €.
MySQL (Course) MySQL (Course)
Management of open-source database. From 39 €.
PHP (Course) PHP (Course)
Full course for creating dynamic Web sites. From 49 €.
Sponsored Links