Apache でURLを書き換える mod_rewrite の使い方をすぐに忘れてしまうのでメモ。

以下は、アクセスのあったURLを rewrite__url というパラメータに押し込んでしまう例。

DirectoryIndex index.php index.html index.htm
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !\.(cgi|css|gif|jp?g|png|php)$
    RewriteRule ^(.+)$ index.php?rewrite__url=$1 [QSA,L]
</IfModule>

その他の例

http://tech.bayashi.jp/archives/entry/techweb/2007/001981...