Most dynamic sites include variables in their URLs that tell the site what information to show the user. Typically, this gives URLs like the following:
The problem with this kind of URL structure is that is not memorable and not search engine "friendly".
A much more better URL is
URL rewrite is the transpation of the last url into something that the server chan understand. That is the original one.
The Apache module
mod_rewrite allows you rewrite URL requests that come into your server and is based on a regular-expression parser.
.htaccess, located in the website root will contain the set of our rules. If the file contains some errors usually the server will display an error code "500".
.htaccess file, any character following the
# character is considered a comment.
The first step is the activation of the Apache rewrite engine. In the
.htaccess file add the following at the beginning of the file
Let's consider a simple example. We want to redirect every access to the following url:
For this to work we need a rewrite rule in the
.htaccess file like the following:
RewriteRule ^articles/?$ articles.php [NC,L]