这个问题已经有了答案:
Reference: mod_rewrite, URL rewriting and “pretty links” explained
4答
.htaccess remove all .php and id as default parameter after slash
2答
Rewrite url to remove question mark and add slashes in htaccess
2答
我只能删除“.php”
重写引擎打开
重写cond%{请求文件名}!-D
重写cond%{request_filename}.php-f
重写规则^(.*)$$1.php[nc,l]
最佳答案
保留前缀并用查询字符串替换最后一部分
RewriteCond %{QUERY_STRING} !^id=
RewriteRule ^root/pages/(.+)$ /root/pages/?id=$1 [L]
需要rewritecond来防止重写循环。
关于php - 如何从此URL“http://localhost/blog/public/post?id = 2”中删除“?id =”? ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56093281/