The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Slim and htaccess / mod_rewrite issue

Juanes's Avatar


26 Jun, 2012 09:40 AM

I'm having trouble making Slim work with this specific project, the folder structure is like this:

- src (main source files) - vendor (some libraries) - webroot (webroot js files images etc)

In the webroot folder I'm using the default .htaccess file that ships with Slim:

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

And when the server's document root is set to project/webroot everything runs fine. But I'm currently unable to change the document root in the production server and so it is the project/ folder. So I created this .htaccess file there:

RewriteEngine On
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]

This is supposed to redirect everything to the webroot folder, and it does, but Slim will always show the / route, even if the requested route does not exist.

/ -> loads / /route-does-not-exist -> loads / /route-exists -> loads /

I tried different htaccess settings but I haven't been able to make it work, can anyone give some advice?

Showing page 2 out of 2. View the first page

  1. 31 Posted by qiyobeta on 05 May, 2017 07:48 AM

    qiyobeta's Avatar

    We will describe you in detail about the folder description.

  2. 32 Posted by Oleksandr Snitk... on 05 May, 2017 09:51 AM

    Oleksandr Snitko's Avatar

    С уважением,
    Снитко Александр
    +38(095) 210-3802
    skype: a.snitko (Thailand)

  3. 33 Posted by Matteo Favaro on 05 May, 2017 10:09 AM

    Matteo Favaro's Avatar

    Matteo Favaro
    Email Principale: matteofavaro (at)
    Cell sui: +41 767396933

  4. 34 Posted by pitozova on 06 May, 2017 01:03 AM

    pitozova's Avatar

    We are giving all the advice to the people.

  5. 35 Posted by oots on 05 Jun, 2017 11:37 AM

    oots's Avatar

    Mod_rewrite is really complicated and you need professional to solve it. The Ex Factor Guide review

  6. 36 Posted by gqws on 07 Jun, 2017 11:25 AM

    gqws's Avatar

    Slim and htaccess is very difficult to control. I talked about my problem at this page

  7. 37 Posted by Stonge on 25 Sep, 2017 12:29 PM

    Stonge's Avatar

    We are looking for the library to study there.

  8. 38 Posted by vuqifure on 27 Sep, 2017 08:28 AM

    vuqifure's Avatar

    Will try to solve this problem.

  9. 39 Posted by cristelaa3 on 27 Dec, 2017 07:13 AM

    cristelaa3's Avatar

    My mod_Rewrite problem is still growing bigger and I don't understand it much. What Men Secretly Want by James Bauer

  10. 40 Posted by rebeccahickshq on 08 Nov, 2018 09:36 AM

    rebeccahickshq's Avatar

    And he tried, trying to get away from the city where it was. I do not know what to put you in the sadness is regret or angry anxiety! He continued on to the game and enjoyed it every single day : <a href="">bloons tower defense 5</a>

  11. 41 Posted by kundan kumar on 04 May, 2020 05:53 AM

    kundan kumar's Avatar

    While checking not found url on url checker tool, shows 200 ok status instead of 404 not found status...
    Plz help i am stuf last one week

    Please check below url on below mentioned tool
    checking tool url here :

    check url here :

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
    RewriteCond %{HTTP_HOST} ^demo.merinoservices\.com [NC]
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://demo.merinoservices\.com/$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.html [QSA,L]

  12. 42 Posted by a-tayar on 10 Jul, 2020 04:30 PM

    a-tayar's Avatar

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac