core icon indicating copy to clipboard operation
core copied to clipboard

flight.base_url not taken into account for routes

Open user478378 opened this issue 10 years ago • 4 comments

A request to /base/books would not be successfully handled by the following setup

Flight::set('flight.base_url', '/base');
Flight::route('/books', function() {});

user478378 avatar Jun 05 '15 11:06 user478378

What is your server configuration and folder structure like? Where are you placing your index.php file?

mikecao avatar Jun 09 '15 20:06 mikecao

I am not quite sure about your question.

You just need to drop the code above into an empty file, route all /base requests to this file and you will notice how it does not work.

My point is that base_url is only used for redirects (Engine._redirect()) but not for anything else such as routes.

user478377 avatar Jun 10 '15 08:06 user478377

Makes sense... I would suggest to add a new option e.g. flight.base_route.

yckart avatar May 18 '16 00:05 yckart

Combination of flight.base_url and flight.base_route could work, but would be nice to handle files moved to a subdirectory globally by a path prefix used for routes, views, ...

  • index.php -- core --- flight -- site --- views --- assets --- ???

So files and routes inside of site should be handled by a global "site" prefix

Flight::set('flight.path_prefix', 'site');
Flight::set('flight.views.path', 'views');  // = default

So render('home', [...]) should load the view site/views/home.php.

It would also help to route assets like JS, CSS or images from a subdirectory.

pwFoo avatar Aug 08 '19 14:08 pwFoo

I just tested this myself and it is working as expected.

n0nag0n avatar Jan 03 '24 21:01 n0nag0n