Question

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.

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

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.

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

EDIT

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.

EDIT 2

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]
Was it helpful?

Solution

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

RewriteBase /flight/

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]

OTHER TIPS

Sorry for giving you an answer that is not going to help a lot. I'm running Flight (also sandboxing) on a subdirectory. I've created an .htaccess just with the defaults in the subdir and Flight is now regarding this as it's root.

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

Did you check the content of the .htaccess on the higher levels, maybe there is something that is blocking you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top