Skip to main content

Close
Get the best research tool on the web today,and free!
Connect with people with common interests!

All Annotations of [Preview]

saved by17 people, first byMarco on 2006-04-25, last byWill Bolton on 2008-07-03

  • onditional statements for RewriteRules.
  • basic format for a RewriteCond is RewriteCond test_string cond_pattern.
  • The .htaccess file is a text file which contains Apache directives. Any directives which
    you place in it will apply to the directory which the .htaccess file sits in, and any
    below it.
  • RewriteEngine on
    RewriteRule ^alice.html$ bob.html
  • RewriteRule
    >
    >
    P
    attern Substitution [OptionalFl
    >a
    >gs]

  • 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.


  • 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 with
      http://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.