.htaccess multiple php handlers based on URL - fatfree framework multiple route files
-
20-06-2021 - |
Вопрос
I'm a bit of a noob when it comes to htaccess files, so I need some assistance. I'm using PHP's fatfree framework (f3), and have modified its htaccess file to suit my needs, until now.
What I'm looking to do is split up/organize fatfree's routing system... so not all routes live in one PHP file.
Here's what I'm hoping to achieve.
- URLS that contain /api/* to get handled by /api/index.php.
- URLS that contain /auth/* to get handled by /auth/index.php
- Any other URL's outside of the above 2 to get handled by /index.php.
With the following .htaccess file, I've been able to achieve #1 & #2 above. #3, not too sure about.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/.* api/index.php [L,QSA]
RewriteRule ^auth/.* auth/index.php [L,QSA]
Any tips are appreciated!
Решение
This should take care of #3:
RewriteCond $1 !^(api|auth)
RewriteRule ^(.*)$ /index.php/$1 [L]
Не связан с StackOverflow