Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 从子目录选择路由_Php_.htaccess_Url Rewriting_Url Routing_Flightphp - Fatal编程技术网

Php 从子目录选择路由

Php 从子目录选择路由,php,.htaccess,url-rewriting,url-routing,flightphp,Php,.htaccess,Url Rewriting,Url Routing,Flightphp,所以我使用flightphp微框架()进行路由。我的问题是,如何在子目录中运行路由器?我的意思是,本质上,在一个文件夹中运行它 与中一样,对“/”的请求只会提取常规index.php文件。但是对“/flight/file”的请求将使用flight加载URL 我知道,您不能将其转储到服务器上的文件夹中,然后期望它工作,因为FlightPHP需要相对于根的URL 有没有一种方法可以将FlightPHP孤立地运行在一个目录中,而网站的其余部分则运行普通的PHP 编辑 我试图简单地将.htaccess文

所以我使用flightphp微框架()进行路由。我的问题是,如何在子目录中运行路由器?我的意思是,本质上,在一个文件夹中运行它

与中一样,对“/”的请求只会提取常规index.php文件。但是对“/flight/file”的请求将使用flight加载URL

我知道,您不能将其转储到服务器上的文件夹中,然后期望它工作,因为FlightPHP需要相对于根的URL

有没有一种方法可以将FlightPHP孤立地运行在一个目录中,而网站的其余部分则运行普通的PHP

编辑

我试图简单地将.htaccess文件放入子目录。这有一个特殊的效果,即导致路由仍然像来自根一样工作(例如/thing/otherthing/当它应该是/otherdirectory/thing/otherthing/),同时导致404回调不工作。不是我想要的

编辑2

.htaccess文件的内容,即Flightphp网站建议的内容:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

很抱歉给了你一个没有多大帮助的答案。我正在一个子目录上运行Flight(也是沙箱)。我已经用subdir中的默认值创建了一个.htaccess,Flight现在将其视为根

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

您是否检查了更高级别的.htaccess的内容,可能有什么东西阻止了您

我知道这是一个老问题,但我一直在做类似的事情,只是添加了一些类似的内容

RewriteBase /flight/
在航班目录的.htaccess文件中(在所有规则之前)。希望这能帮助其他人寻找同样的东西。例如:

RewriteEngine On
RewriteBase /flight/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

只需将
.htaccess
文件添加到运行框架的目录中-您尝试过吗?请发布
.htaccess
文件的内容好吗?这样的信息对于找出问题所在非常有帮助。