Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess for framework MVC,解锁文件夹_Php_.htaccess_Directory Structure - Fatal编程技术网

Php htaccess for framework MVC,解锁文件夹

Php htaccess for framework MVC,解锁文件夹,php,.htaccess,directory-structure,Php,.htaccess,Directory Structure,我对该文件有一个问题,可能是htaacess ### htaccess ### Options -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] ErrorDocument 404 /erro

我对该文件有一个问题,可能是htaacess

### htaccess ###

Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
ErrorDocument 404 /error/404
ErrorDocument 403 /error/403
该文件运行良好,但当我的正常web地址为:localhost/mvc/index.php或localhost/mvc/index.php或localhost/mvc/post/view/22时,它无法提供安全性

在这个岗位上,一切都很顺利。 当我的网址包含文件夹+文件时,会出现此问题

localhost/mvc/models/post_model.php

localhost/mvc/public/layout.php

localhost/mvc/images/testimg.png

localhost/mvc/config/db.php

例如,它都是一个文件夹/文件,您现在可以打开数据库配置文件 当我打开文件时,我应该会得到一个错误,因为这样的文件包含配置和类似的东西。 我的index.php文件如下所示:

### index.php ###

<?php
$on = 1;
if ($on == 1) {
    error_reporting(1);
    ini_set('display_errors', 1);
}
require 'libs/bootstrap.php';
require 'libs/Controller.php';
require 'libs/Model.php';
require 'libs/Database.php';
require 'libs/Session.php';
require 'libs/View.php';
require 'libs/Jyll.php';
require 'config/db.php';
Session::init();
$bootstrap = new Bootstrap();
主要结果是require、include和其他活动的文件以其他方式打开,崩溃或重定向上述页面上的403错误。
我想访问所有内容,如果根目录中只有index.php文件

那么如果您只想在根目录中使用index.php,那么显而易见的解决方案是将代码的其余部分移到web根目录之上,对吗?从开始页开始,只对index进行访问,其余部分位于子文件夹中,如model、config、view、public、controller、,等当我们进入/var/www/index.php MVC时,只能看到.htaccess和现在只能访问be index.php的文件夹和文件夹,当网址中有人单独键入此文件夹时,此文件夹将出错。这与MVC体系结构模式没有任何关联。