我有像http://localhost/site/blog.php?id=31
这样的网址,并且在页面blog.php上使用了id来获取内容,但是我想为此目的显示像http://localhost/site/blog/id/31
这样的网址。如果url显示如localhost/site/id/3
1或任何其他类似的模式。只是显示内容的代码是在blog.php中,它使用ID参数来显示内容。我已经尝试了以下方法,但迄今为止没有任何工作。你所有专家的帮助吗?使用htaccess更改或隐藏网址
RewriteEngine On
RewriteRule ^([^/]+)/?$ site/blog?id=$1 [QSA]
和
RewriteEngine On
RewriteRule ^/?id/([^/]+)/?$ site/blog.php?id=$1 [L,QSA]
可能的重复[参考: mod \ _rewrite,URL重写和“漂亮链接”解释](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) –