I have a folder structure like this:
.cpanel/
public_html/
public_ftp/
..
and a laravel project inside the public_html directory like this:
app/
bootstrap/
public/
vendor/
composer.json
artisan
..
The problem was that when I entered the url like www.example.com, it would redirect to www.example.com/public.
I found a rewrite rule that allowed me to put in www.example.com and it would just show public/index.php
without the "/public" part:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
It worked for the index page, but when I try to go to any of the routes, "/public" shows back up in the URL.
Why does this rewrite rule work for the index page and not for any of the routes? What rewrite rule will work for all of the pages to remove "/public" from the URL?