![]() |
||||||||||||
|
||||||||||||
|
Razer Technology Solutions, Inc.
|
Module mod_rewrite
Tutorial (Part 1): The Apache Server Power Commander You may have encountered
the name "mod_rewrite" before when surfing the web. For all
of Its primary function
is the manipulation of URLs. The module is very versatile as we are going
to To steer clear from this, we will start off with some very simple examples. Before we can get
going, however, you will have to check whether the module is installed
on your web 1. Ask your system
administrator - provided he or she knows. They really should, but 2. Check your Apache
configuration file if you can access it. One possible standard path might
be: 3. Check it out with
one of the following examples. If it works fine, mod_rewrite is indeed
installed Also, you will see
this entry in file "error.log": "Invalid command 'RewriteEngine',
perhaps mis-spelled If your site generates
heavy traffic, this method is not recommended, as every visitor will receive We will assume that
you will be using mod_rewrite only for your own web site, i.e. not as
a generalized The .htaccess File If you already have a ".htaccess" file, for example one with the following entries: Options Includes +ExecCGI
simply add our code sample to it.
The first two entries will start the module: RewriteEngine on Tip: Entry "RewriteEngine
off" will override all subsequent commands. This is a very useful
feature: If your system administrator
does not allow for implementation of "Options +FollowSymlinks",
you will The next required entry is this: RewriteBase / "/" stands
for the base URL. Should you have another And now to the entries proper! Let us assume that
you want to block unauthorized access to your file .htaccess. On some
servers RewriteRule ^\.htaccess$ - [F] This rule translates to: If someone tries to access file .htaccess, system shall generate error code "HTTP response of 403". The file name ^\.htaccess$ is contained in a regular expression, to wit: ^ Start of line anchor The file name must
be located exactly between start and end of line anchor. This will ensure
that only [F] : special flag "forbidden". In this example, the complete ".htaccess" file will now consist of these lines: RewriteEngine on If we add our code to a pre-existing ".htaccess" file, we might, for example, get the following entries: Options Includes +ExecCGI
A Users Guide to URL Rewriting with the Apache Webserver: http://www.engelschall.com/pw/apache/rewriteguide/ This text may freely be republished or distributed provided the following resource box is included intact either at the beginning or the end of the article and a complimentary copy or notice (link) is sent to the author at the address specified below: Dirk Brockhausen is
the co-founder and principal of fantomaster.com Ltd. (UK) and fantomaster.com
GmbH |
|
|||||
| home · services
· about us · copyright
· the eZine · contact
· customer site Copyright © Razer Technology Company 1999 - 2008. Legal Disclaimer Site Mod:1/2008. |