JavaScript Editor Ajax software     Free javascripts 



Main Page

You can find the official documentation of mod_rewrite at
http://httpd.apache.org/docs/2.2/
rewrite/
. The introduction to mod_rewrite is located at
http://httpd.apache.org/docs/
2.2/rewrite/rewrite_intro.html
. There are multiple books dedicated to mod_rewrite. We
recommend
The Definitive Guide to Apache mod_rewrite
(Apress, 2006).
The rest of this chapter is dedicated to URL rewriting, using various exercises covering the following:
?
Installing mod_rewrite
?
Testing mod_rewrite
?
Working with regular expressions
?
Rewriting numeric URLs with two parameters
?
Rewriting keyword-rich URLs
?
Building a link factory
?
Pagination and URL rewriting
?
Rewriting images and streams
Installing mod_rewrite
If you’re implementing the exercises in this book using an external hosting provider, it’s very likely that
mod_rewrite is already installed and enabled. In that case, you can simply skip to the next section, “Testing
mod_rewrite.” Consult your web host for information regarding whether mod_rewrite is supported and
enabled.
If you’ve installed Apache yourself, read on. Because of its popularity, mod_rewrite is now included
with all common Apache distributions. If desired, you can verify if your Apache installation has the
mod_rewrite module by looking for a file named
mod_rewrite.so
under the
modules
folder in your
Apache installation directory.
However, mod_rewrite may not be enabled by default in your Apache configuration. To make sure,
open the Apache configuration file, named
httpd.conf
. If you’ve installed Apache using the XAMPP
package as instructed in Chapter 1, the full path of the file will be
\Program Files\xampp\apache\
conf\httpd.conf
.
Open
httpd.conf
and find the following line:
#LoadModule rewrite_module modules/mod_rewrite.so
The leading
#
means the line is commented, so remove it in order to have Apache load the mod_rewrite
module upon its startup:
LoadModule rewrite_module modules/mod_rewrite.so
After any change to
httpd.conf
, you need to restart the Apache server in order for the changes to take
effect. In case you run into trouble, you can check Apache’s error log file (
/logs/error.log
), which
should contain the details of the error.
48
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 48


JavaScript Editor Ajax software     Free javascripts