来自子目录的Flight PHP路由 [英] Flight PHP Routing from Subdirectory

查看:83
本文介绍了来自子目录的Flight PHP路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用Flight PHP微框架( http://flightphp.com/ )进行路由。我的问题是,如何从子目录中运行路由器?我的意思是说,从本质上讲,它是在文件夹中沙盒运行。

So I'm using the Flight PHP microframework (http://flightphp.com/) to do routing. My question is, how can I run the router from within a subdirectory? What I mean is, essentially, run it 'sandboxed' within a folder.

在这种情况下,对 /的请求只会拉出常规的index.php文件。但是对 / flight / file的请求将使用Flight来加载URL。

As in, a request to '/' just pulls the regular index.php file. But a request to '/flight/file' would load the URL using Flight.

我知道您不能只是将其转储到服务器上的文件夹中并期望它之所以能够正常工作,是因为FlightPHP需要相对于根的URL。

I know you can't just dump it in a folder on the server and expect it to work because FlightPHP expects the URLs relative to the root.

有没有一种方法可以在目录中隔离运行FlightPHP,而网站的其余部分则运行常规PHP?

Is there a way to run FlightPHP isolated in a directory with the rest of the website running regular PHP?

编辑

我尝试将.htaccess文件放入子目录中。这具有使路由仍然像从根开始一样起作用的特殊效果(例如/ thing / otherthing /当它应该是/ otherdirectory / thing / otherthing /时),同时导致404回调不起作用。

I tried simply putting the .htaccess file into the subdirectory. This has the peculiar effect of causing the routes to still act as if they are from the root (e.g. /thing/otherthing/ when it should be /otherdirectory/thing/otherthing/ ) while simultaneously causing the 404 callback to not work. Not what I intended.

编辑2

.htaccess文件的内容,以下是Flightphp网站建议的内容:

Contents of .htaccess file, which are what is suggested by the Flightphp website:

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


推荐答案

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

I know this is an old question but I've been doing something similar just by adding something along the lines of

RewriteBase /flight/

飞行目录的.htaccess文件(所有规则之前)。希望这可以帮助其他人寻找相同的东西。示例:

in the .htaccess file (before all of your rules) of the flight directory. Hope this helps someone else looking for the same thing. Example:

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

这篇关于来自子目录的Flight PHP路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆