Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

359
Views
Laravel remove public route AND disable it for accessing

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 ?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!