Search code examples
.htaccessslim

Configure htaccess for Slim Framework


I have this directories structure on my server:

site.com/www/index.php
site.com/www/api/Slim
site.com/www/api/index.php

I want configure Slim for use as rest-api interface in 'api' folder. How can i configure htaccess in api folder for it?

Note. in www/ i have other htaccess and index.php for my project, i think this should not prevent. htaccess in www folder:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php

Solution

  • You need to set your RewriteBase to folder where Slim application is located.

    RewriteEngine On
    RewriteBase /api/
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [QSA,L]