【发布时间】:2014-07-06 15:11:51
【问题描述】:
我正在为我的 php Web 应用程序创建一个 MVC 结构。 这是一个 Windows 8.1 系统,运行 xampp。 .htaccess 文件无法正常工作。它位于此处:
C:\xampp\htdocs\hmb
当我在 Firefox 中打开这个网址时:
http://localhost/hmb/test
我想要处理这个:
http://localhost/hmb/index.php?url=page
但我收到错误 (404)。
这是我的 .htaccess 文件内容:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
$_GET['url'] in index.php 只是不存在。 我配置了 httpd.conf 文件。 我做错了什么?
【问题讨论】:
-
@nietonfir 当我说它不存在时,我的意思是,当然,它没有作为参数传递。其他一切都没有意义。我从一个流行的 youtube 视频中获得了这段代码,名为“PHP:创建你自己的 MVC(第 1 部分)”,所以我认为它没有错。如果您知道有用的答案,请不要犹豫发布它。
-
@ChristophBühler 是的 .. 好吧 .. 那个视频太糟糕了。而且完全错误。 MVC 与目录结构或漂亮的 URL 无关。 MVC 模式定义了应用层之间信息流的约束。
标签: php regex apache .htaccess mod-rewrite