Skip to main content

Remove public from url laravel 5.4

Step 1: Rename File

In first step it is very easy and you need to just rename file name. you have to rename server.php to index.php at your laravel root directory.

server.php
INTO
index.php

Step 2: Update .htaccess

first of all you have to copy .htaccess file and put it laravel root folder. You just copy .htaccess file from public folder and then update bellow code:

.htaccess

Options -MultiViews -Indexes

RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/public/ RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

Documentation : https://hdtuto.com/article/laravel-remove-public-from-url-using-htaccess

Comments

Popular posts from this blog

Generate Laravel migrations and seeders from an existing database

In conclusion, migrating existing PHP applications to laravel can be a challenging task, perticularly when dealing with large databases and tables. As a developer we need a solution which automates the migration and seeder generation.Thankfully, there are handy packages available to automate the migration and seeder generation processes. For generating migrations, you can utilize the ` kitloong/laravel-migrations-generator ` package. First we will generate migrations from database tables Run below command      composer require --dev kitloong/laravel-migrations-generator Running below command will generate migrations for all tables           php artisan migrate:generate If you want to create migrations for specific tables then use below command           php artisan migrate:generate --tables="table1,table2,table3" You can also ignore some tables using           php artisan migrate:g...

Build laravel crud using infyom laravel generator

Installation of Laravel First you need to install laravel by running below composer commands     composer create-project laravel/laravel example-app After creating project run artisan command to initialize development server     cd example-app     php artisan serve Now you can access your application in your web browser at http://localhost:8000 Installing Infyom laravel generator Now you need to install laravel generator by infyom. Add following packages into composer.json while using it with Laravel 9.     "require": {                  "infyomlabs/laravel-generator" : "^5.0",                  "infyomlabs/adminlte-templates" : "^5.0"      } if you want to use Generate from table option, you need to install       "require": {                  "doctrine/dbal" : "^2.3"     ...

Introduction Of Laravel

Laravel is a PHP based web framework for building high-end web applications using its significant and graceful syntaxes. It comes with a robust collection of tools and provides application architecture. Moreover, it includes various characteristics of technologies like ASP.NET MVC, CodeIgniter, Ruby on Rails, and many more. This framework is an open-source framework. It facilitates developers by saving huge time and helps reduce thinking and planning to develop the entire website from scratch. Along with that, the security of the application is also taken care of by Laravel. So all its features can increase the speed of web development for you. If you are familiar with intermediate PHP scripting and PHP basics, Laravel can prepare your work more efficiently. The current version of Laravel is  9 , which is a stable release, released on  February 8, 2022 . And anyone can check its open-source GitHub repository from this link below: https://github.com/laravel/framework Laravel Fa...