Try this rule in your /project/.htaccess
:
RewriteEngine On
RewriteBase /project/
RewriteCond !/src/ [NC]
RewriteRule ^(.*)$ src/$1 [L]
Make sure this is your first rule.
Question
I want make two slim app, one for api calling and another one for website users.
I put my main php file into 'src' directory, and the structure is as below:
/
---.htaccess
---/src(here are files)
-----.htaccess
-----index.php(Slim)
-----/Controllers
-----/Views
-----/Models
-----/api
-------.htaccess
-------index.php(Slim)
---/public
-----/js
-----/css
-----/fonts
i want to make my url from this:
http://localhost/project/src/api/foo
to
http://locahost/project/api/foo
I don't know how to write the first .htaccess
(root)
i try to redirect to subdir like this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^src/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ src/ [QSA,L]
but it always returns 404 Not found by Slim. i thought it did redirect to subdir but the slim router wont get correct url, am i right?
and others looks like this:(I just copy the documentation from SlimFramework)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA]
any ideas would help me a lot! thank you!
Solution
Try this rule in your /project/.htaccess
:
RewriteEngine On
RewriteBase /project/
RewriteCond !/src/ [NC]
RewriteRule ^(.*)$ src/$1 [L]
Make sure this is your first rule.