Question

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.

  1. URLS that contain /api/* to get handled by /api/index.php.
  2. URLS that contain /auth/* to get handled by /auth/index.php
  3. 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!

Was it helpful?

Solution

This should take care of #3:

RewriteCond $1 !^(api|auth)
RewriteRule ^(.*)$ /index.php/$1 [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top