flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.62k stars 409 forks source link

Routes other than `/` don't work #472

Closed ehsanghorbani190 closed 8 months ago

ehsanghorbani190 commented 2 years ago

Hi! this is my index.php file:

<?php
require 'vendor/autoload.php';

Flight::route("/atu" , function(){
    echo "HI";
});
Flight::route('/', function(){
    echo 'hello world!';
});

Flight::start();

and this is my .htaccess file:

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

and this is what i get when i try to access localhost/atu: image

Where's the problem?!

Update: I just tested it on a server and it works fine, but i cant use it on my local machine.

kuopassa commented 2 years ago

Is your website on localhost available directly at http://localhost, or is it in subfolder, like http://localhost/atu/? If it's the latter, then you might need to add this to your .htaccess file below RewriteEngine On:

RewriteBase /atu/

paxperscientiam commented 1 year ago

Check the server logs.

EDIT: Also, all of those htaccess rules can be replaced with this: FallbackResource /index.php # or whatever your main file is called

krmu commented 8 months ago

@ehsanghorbani190 does this problem still exists?

ehsanghorbani190 commented 8 months ago

@krmu honestly I don't know. I've moved from that project and also PHP.