How to create a rewritecond/rule

Discussion in 'General' started by Pasco, Jun 23, 2011.

  1. Pasco

    Pasco Member

  2. slatz

    slatz New Member

  3. Pasco

    Pasco Member

    works perfectly - thanks!

    Just for my understanding: I could have done that with mod_rewrite too?

    Cheers, [email protected]
  4. slatz

    slatz New Member

    yeah you could have, something like this:

    RewriteEngine on
    RewriteRule ^demo\demo.iso$ demo.html

    The caret, ^, signifies the start of an URL, under the current directory. This directory is whatever directory the .htaccess file is in. You’ll start almost all matches with a caret.

    The dollar sign, $, signifies the end of the string to be matched. You should add this in to stop your rules matching the first part of longer URLs.

    The period or dot before the file extension is a special character in regular expressions, and would mean something special if we didn’t escape it with the backslash, which tells Apache to treat it as a normal character.

    So, this rule will make your server transparently redirect from demo\demo.iso to the demo.html page. Your reader will have no idea that it happened, and it’s pretty much instantaneous.

    NOTE: RewriteEngine on (only needs to be specified once in your .htaccess file).

Share This Page