如何将URL参数更改为斜杠?

时间:2018-02-08 05:20:13

标签: php

我想更改我网站的网址:

http://localhost/bimbsec/v3/index.php?p=page-name

http://localhost/bimbsec/v3/page-name

我可以使用纯PHP函数吗?还是有最好的办法?

1 个答案:

答案 0 :(得分:0)

将此文件另存为项目目录中的.htaccess,然后像

一样运行

http://localhost/test/test-page

您将获得类似$ _GET var

的测试页面

数组([p] =>测试页面)

<IfModule mod_rewrite.c>

  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule (.*) index.php?p=$1& 
</IfModule>
相关问题