Boilerplate to use a Directus Instance to Build a Custom Website, Content will be Manage by Directus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
962 B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php
  2. require __DIR__.'/../vendor/autoload.php';
  3. require __DIR__.'/../app/bootstrap.php';
  4. // make sure that all routes with a slug and ending with a "/" redirect to a route without
  5. $flight->route('GET /@slug:[a-z0-9\-]+/$', function() use ($flight) {
  6. // getting position and build route
  7. $position = strlen($flight->request()->url) - 1;
  8. $route = substr_replace($flight->request()->url, '', $position, 1);
  9. $flight->redirect($route, 301);
  10. });
  11. $flight->route('GET /404', array(new App\Controllers\PageController, 'notFoundAction'));
  12. $flight->route('GET /feed', array(new App\Controllers\FeedController, 'indexAction'));
  13. $flight->route('GET /blog/@slug:[a-z0-9\-]+$', array(new App\Controllers\PostController, 'getAction'));
  14. $flight->route('GET /(@slug:[a-z0-9\-]+$)', array(new App\Controllers\PageController, 'getAction'));
  15. $flight->start();
  16. try {
  17. $flight->start();
  18. } catch (\Exception $exception) {
  19. echo $exception->getMessage();
  20. }