slim framework htaccess 404 not found

I know there are many such questions and I have tried them all but none seems to work.

User directories are configured and so I can open localhost/~h22 (h22 is username)

http://localhost/~h22/slim/index.php/hello/Megh works but http://localhost/~h22/slim/hello/Megh doesnot work giving 404 not found error

Exact error in browser

Not Found

The requested URL /home/h22/public_html/slim/index.php was not found on this server.

.htaccess file is parsed as writing gibberish in the file gives internal server error.

My code is located in

/home/h22/public_html/slim
├── composer.json
├── composer.lock
├── .htaccess
├── index.php
└── vendor
    ...

index.php:

<?php
require 'vendor/autoload.php';
$app = new SlimSlim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, " . $name;
});
$app->run();
?>

.htaccess:

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

/etc/httpd/conf.d/slim.conf:

<Directory "/home/h22/public_html/slim">
    AllowOverride All
    Require all granted
</Directory>


Source: apache

Leave a Reply