次の書き換えルールは、単純な PHP サイトで .htaccess に使用されています。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteRule ^index\.php$ - [L]
RewriteRule ^([a-zA-Z-]+)/?$ /test/index.php?m=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test/index.php [L]
</IfModule>
次の URL は正常に機能します。
domain.com/test/index.php?m=profile
domain.com/test/profile
domain.com/test/profile/
ただし、追加のクエリ パラメータは書き換えにより失われます。
domain.com/test/index.php?m=profile&id=2000 ==> works
domain.com/test/profile?id=2000 ==> does not work
domain.com/test/profile?id=2000 ==> does not work
どんな助けでも感謝します。