How to Remove Public from URL in Laravel 10?
This article goes in detailed on how to remove public from url in laravel 10. you can see remove public from url laravel 10 using htaccess. This example will help you remove public from url in laravel 10 with htaccess. In this article, we will implement a remove public from laravel 10 htaccess. you will do the following things for laravel 10 remove public from url.
Sometime we upload laravel application code on shared hosting and you want to run it. Then we can not set directly path of index.php with shared hosting. so we must need to run app with "public" folder. so, you will face issue with "public" in url. here, i will give you two solution how to remove public from url in laravel application.
I will suggest you don't have to use "shared hosting" for laravel application and never go for this solution.
Solution 1: Laravel Remove Public From URL using .htaccess
In Laravel, the .htaccess file can be generated and edited to incorporate new changes. The .htaccess file is located in the root directory, and its modification requires mod_rewrite to be enabled on your Apache server. It is mandatory to enable the rewrite module to implement these changes. Moreover, you need to activate .htaccess in Apache virtual host to use it in Laravel.
Finally, Just go to root folder and create .htaccess file and upload with following code
RewriteRule ^(.*)$ public/$1 [L]
Solution 2: Rename server.php and Move .htaccess File
To remove "public" from your Laravel URL, you need to complete the following two steps:
1. Rename the server.php file in your Laravel root folder to index.php.
2. Copy the .htaccess file located in the /public directory to your Laravel root folder.
3. All public folder css and js file move to root folder.
I hope it can help you...
We are Recommending you
- Laravel 10 Image Validation Rule Example
- Laravel 10 Custom Login and Registration Example
- Laravel 10 Custom Forgot Password Example
- Laravel 10 Email Verification Tutorial Example
- Laravel 10 Send SMS using Twilio Tutorial Example
- Load More Data on Button Click using JQuery Laravel 10
- Laravel 10 Store Backup on Dropbox using Spatie Tutorial
- Laravel 10 Many to Many Eloquent Relationship Tutorial
- Laravel 10 Scout Full Text Search Tutorial
- Laravel 10 JQuery UI Ajax Autocomplete Search Example
- How to Get Last Executed Query in Laravel 10?
- Laravel 10 Select2 Ajax Autocomplete Search Example
- Laravel 10 Ajax Request Example Tutorial
- Laravel 10 Multiple File Upload Tutorial Example