how to remove=和?从php中的url

dced5bon  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(301)

我要删除?和=从我的url“http://localhost/g-zip/offices-view.php?id=11041“使用.htaccess。我使用此代码从url中删除扩展名。

从url中删除.php

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
xpszyzbs

xpszyzbs1#

尝试在php中使用str\u replace()函数:

echo str_replace("?",""," http://localhost/G-Zip/offices-view.php?id=11041");

上面的代码会删除吗?从url

echo str_replace("=",""," http://localhost/G-Zip/offices-view.php?id=11041");

上面的代码将从url中删除=

相关问题