Htaccess redirect not working

Hi, Locally, I have slim installed in http://localhost/slim/public and can access a hello world in this directory.
However, I would like to serve content from http://localhost/slim/ and for this, I created a .htaccess file in the /slim directory with the following…

RewriteEngine on
RewriteRule ^$ slim/public/ [L]
RewriteRule (.*) slim/public/$1 [L]

However, Apache gives me an internal server error page when trying http://localhost/slim

I also have this in my index.php

$app = AppFactory::create();
$app->setBasePath('/slim/public');

The other requirements have been met in accordance to https://www.slimframework.com/docs/v4/start/web-servers.html#apache-configuration

What do I need to get things working from http://localhost/slim/

Thanks.

Hi!

Did you also create the 2nd .htaccess file according to the documentation?
Please just copy the two .htaccess exactly as they are documented. You don’t need to change it.

Then set the Slim basePath to /slim and try it again.

1 Like

Thanks, that worked.

1 Like