使用 URL 重写从 URL 隐藏查询字符串参数


hidequery string parameters from the url using url rewriting

在我的php网站中,我需要以特定的方式显示我的骨灰盒

我需要隐藏查询字符串参数,只想在 URL 中显示值即

mydomain.com/city.php?place='usa'&id=2

我需要显示

my domain.com/city-2/usa

可能吗?

请帮助我。我的情况很严重。

提前致谢

是的,有可能:

RewriteEngine On
RewriteBase /
RewriteRule ^city-('d+)/(.*) city.php?place=$2&id=$1

您需要将其放入放置在网站网络根目录中的.htaccess中。要使其正常工作,您需要启用.htaccess解析并启用mod_rewrite apache 模块(假设您将 apache 作为 Web 服务器)。

官方文档中的更多内容