gpt4 book ai didi

.htaccess 在我的 PHP MVC 框架中不起作用

转载 作者:行者123 更新时间:2023-12-04 05:01:23 24 4
gpt4 key购买 nike

我正在 ubuntu 上从头开始构建我自己的 PHP MVC 框架。 .htaccess文件在其中不能正常工作。文件夹结构和.htaccess文件内容如下。

文件夹结构

/MyMVCProject
/controllers
index.php
help.php
/libs
/modles
/views
.htaccess
index.php
.htaccess文件内容
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

当我输入 localh0st/MyMVCProject/help它给了我以下错误。

Not Found
The requested URL /MyMVCProject/help was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localh0st Port 80



而且我确定我已经启用了 mod_rewrite。

最佳答案

尝试这样做,从 $_REQUEST您可以获取 url 参数并在 index.php 文件中处理它。

也用于测试目的添加

echo <pre>;
print_r($_REQUEST);
echo </pre>;

index.php 的第一行
<ifModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteRule ^(.*)$ /$1 [R=301,L]
</ifModule>

关于.htaccess 在我的 PHP MVC 框架中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16118987/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com