How to remove public from url in laravel?

Member

by lily , in category: PHP Frameworks , 10 months ago

How to remove public from url in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lottie , 10 months ago

@lily 

To remove "public" from the URL in Laravel, you can utilize the Apache virtual host configuration.


Follow these steps:

  1. Open the Apache virtual host configuration file for your Laravel project. This file is typically located in the /etc/apache2/sites-available directory.
  2. Look for the DocumentRoot directive in the virtual host configuration file. Modify the value of this directive to point to the public directory of your Laravel project. For example, change it from "/var/www/html" to "/var/www/html/public".
  3. After making the changes, save the file and exit the text editor.
  4. Restart the Apache web server to apply the changes. You can do this by running the following command:
1
sudo service apache2 restart


  1. Test the website access by visiting your Laravel project URL without "public" in it. The URL should now directly point to your Laravel application without displaying the "public" segment.


By following these steps, you can remove "public" from the URL in your Laravel project and access it directly from the root domain.

Related Threads:

How to redirect public to non public url with .htaccess?
How to remove id from url in laravel?
How to remove index.php from the url in laravel?
How to remove hash from form action url in laravel?
How to redirect to public in laravel?
How to save download zip to public folder in laravel?