when i visit localhost/project
I get this error
Forbidden
You don't have permission to access this resource.
Apache/2.4.29 (Ubuntu) Server at localhost Port 80
when i try to access project root directory, my index.php
is in public
folder (project/public/index.php)
so i use .htaccess
to redirect requests to public folder but this doesn’t seem to work
i tried to set AllowOverride All
but didn’t help
i tried to change all project permissions even to 777
still didn’t work
here is my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} /public/([^s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
i am using ubuntu 18.08 – PHP 7.3 – Apache
2
Answers
Just put this in your project folder .htaccess
You can have this in
/project/.htaccess
:Then have this rule in
project/public/.htaccess
: