私の .htaccess ファイルには次のものがあります。これにより、.php 拡張子が削除され、ディレクトリでない場合は残りの部分のスラッシュが削除されます。ただし、これを変更してクエリ文字列も変更したいと思います。
AddType text/x-component .htc
RewriteBase /
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
{root}/file?id=1 を /file/1 に変更し、{root}/directory/file?id=1 を {root}/directory/file/1 に変更したい
どんな助けでも大歓迎です!