我的 .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
任何帮助是极大的赞赏!