core icon indicating copy to clipboard operation
core copied to clipboard

Routes other than `/` don't work

Open ehsanghorbani190 opened this issue 3 years ago • 2 comments

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.

ehsanghorbani190 avatar Jul 31 '22 04:07 ehsanghorbani190

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/

kuopassa avatar Jul 31 '22 15:07 kuopassa

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

paxperscientiam avatar Sep 13 '22 03:09 paxperscientiam

@ehsanghorbani190 does this problem still exists?

krmu avatar Jan 03 '24 20:01 krmu

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

ehsanghorbani190 avatar Jan 04 '24 10:01 ehsanghorbani190