flightphp / core

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

having index.php in subdirectory #461

Closed ftheron15 closed 8 months ago

ftheron15 commented 2 years ago

Hi,

I don't know if it's an issue or if it's my bad, but I've a problem with the routing and the file .htaccess

I put my index.php in the directory /a/b and I want to redirect my request to this directory in the .htaccess. My request is GET http://localhost/myProject/users I follow the documentation without sucess.

.htaccess

RewriteEngine On
RewriteBase /a/b/

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

index.php

Flight::route('GET /users', array($UserController,'getAllUsers'));
Flight::start();

I found two solutions to debug it but I can't keep this. with the .htaccess like this

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ a/b/index.php [QSA,L]
http://localhost/myProject/a/b/users

index.php

Flight::route('GET /*/users', array($UserController,'getAllUsers'));
Flight::start();

Do you know how to :

Thank you in advance

mosababdo commented 2 years ago

See this https://stackoverflow.com/questions/11784073/apache-rewrite-rule-to-redirect-all-request-to-subdirectory-containing-another https://stackoverflow.com/questions/28970616/rewrite-rule-in-subdirectory https://stackoverflow.com/questions/65109212/how-can-i-use-the-htaccess-file-to-rewrite-urls-for-a-subdirectory

n0nag0n commented 8 months ago

This seems addressed. If not, let's create another issue.