I am using Laravel 7 within my last project. I used the same approach on all my Laravel projects to remove the 'public' from the route: - create a .htaccess within the root folder and add:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
I agree, that this method is all around the google and also works locally. Everything perfect until here.
The problem is that I made a facebook ad campaign on this project which points to the homepage (/) of the website and also added a 'Book Now' button with a link to it. The strange thing is that the link from Facebook ad, points to mywebsite.com/public even I specified only mywebsite.com so I just tried to manual access that route with public, and it worked.
So looks like my website's homepage is / and /public/ in the same time. I want to be accessible only on / and disable the 'public'. Maybe if it's still specified, to be redirected to /. I also read about that kind of fix to rename 'server.php' to 'index.php' and copy the .htaccess from public to the root, but there are a lot of negative advices not to do this for security reasons.
What would be the proper and also secure way to achive this ?