.htaccess模式重写不影响页面url


.htaccess mode rewrite does not affect page url

我知道这个问题在整个互联网上都得到了回答,但这些都没有帮助到我。我看了这里,没有人帮我。

我需要有清晰的url

我有这个urlhttp://localhost/projekt-vb/index.php?page=example

我需要地址像这样localhost/project -vb/example

我用了这个

RewriteEngine on
RewriteRule ^([a-z]+)/?$ index.php?page=$1 [L,QSA]

但对我来说,它没有解决任何问题。我知道它无处不在,但没有人能帮助我写我做错了什么。我都快疯了

我的文件树是:

projekt-vb/
   admin/
   core/
   modules/
   template/
       cont/
       css/
       imgs/
       example.php
   .htaccess
   index.php

所有这些文件?page=example将被放置在template/cont/

原始网址:http://localhost/projekt-vb/index.php?page=example

重写URL: localhost/project -vb/example

放置文件夹下的htaccess文件project -vb

RewriteEngine on
RewriteBase /projekt-vb/
RewriteRule ^([a-z]+)/?$ index.php?page=$1 [L,QSA]

当你在本地主机上重写url时,你必须指定你的项目存在的文件夹名,导致在htdocs或www文件夹中我们是你,这是我们的public_html作为live网站。

所以你必须告诉文件夹你的基础路径为url重写

你的文件结构必须是这样的

projekt-vb/
   admin/
   core/
   modules/
   template/
       cont/
       css/
       imgs/
       example.php
  .htaccess
  index.php

现在在index.php中,您可以按照下面的

获取页面
$pagename=$_GET["page];