mod_rewrite, a beginner's guide (with examples)
Popularity Report
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
URL Tag Cloud
Bookmark History
Saved by 23 people (7 private), first by anonymouse user on 2006-04-25
- Elroyjetson on 2008-03-21 - Tags Development , HowTos
- Skabber on 2008-03-20 - Tags webdev
- Glennm on 2008-02-16 - Tags mod-rewrite , php
- Echohelloworld on 2008-01-28 - Tags apache , dev , mod_rewrite , server
- Funkadelicsoul on 2008-01-11 - Tags htaccess , mod-rewrite , programming , website-development
Public Sticky notes
Highlighted by djshiow
RewriteCond test_string cond_pattern.
Highlighted by djshiow
Highlighted by bobblebob
Highlighted by bobblebob
Highlighted by bobblebob
You can include backreferences and server variable names (%{VARNAME})
in the substitution. Backreferences to this RewriteRule should be written as
$N, whereas backreferences to the previous RewriteCond should be written
as %N.
A special substitution is -. This substitution tells Apache to not
perform any substitution. I personally find that this is useful when using the
F or G flags (see below), but there are other uses as well.
Highlighted by bobblebob
This is the only part of the RewriteRule which isn’t mandatory. Any flags which you use should be surrounded in square brackets, and comma separated. The flags which I find to be most useful are:
-
F- Forbidden. The user will receive a 403 error. -
L- Last Rule. No more rules will be proccessed if this one was successful. -
R[=code]- Redirect. The user’s web browser will be visibly redirected to the substituted URL. If you use this flag, you must prefix the substitution withhttp://www.somesite.com/, thus making it into a true URL. If no code is given, then a HTTP reponse of 302 (temporarily moved) is sent.
Highlighted by bobblebob


Public Comment