How to remove public from url in laravel 9 hi i am working with laravel 9 and i uploaded my project to a server. i am using cpanel my project files are in public_html. now xyz.com/public/xxx and xyz.com/xx reach the same address as if all my routes have been copied on the server.
Point to public as document root. Many past discussions on this.
@jlrdw I've seen other discussions but I don't understand what to do.can you explain how to do it?
@urwxgrwx I am guessing linux and apache:
https://www.tutorialspoint.com/how-to-setup-virtual-hosts-with-apache-web-server-on-linux
Or you leave the htaccess file alone in public and add a second to root with:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^ [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
@tray2 has one also, I don't have link, but a search will find it. But the virtual host is preferred.
If you use Nginx, the documentation fully covers that.
Edit:
See if your host has any tutorials on this, many do.
Please sign in or create an account to participate in this conversation.