.htaccess rewrite rules

Memo: if you use multiple rewrite rules in your .htaccess file, remember that each RewriteRule must follow the necessary RewriteCond, e.g. you can not pack all rules. Thus, this doesn’t work:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)/([^/]+)$ index.php?jid=$1&mode=$2 [L,QSA]
  RewriteRule ^(.*)$ index.php?jid=$1 [L,QSA]

while this works smoothly.

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?jid=$1&mode=$2 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)/([^/]+)$ index.php?jid=$1 [L,QSA]

Of course I stumbled upon this while hacking at my jabber presence agent.


Commenti

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.