Remove public from URL at live server - Laravel

Remove public from URL at live server - Laravel

Sometime shared hosting create /public url issue. I face this issue many time with my Laravel 6, Laravel 7 and Larave  8 project. So, what i use for solve this issue, i am going to share with you.  /public is not good to look and also it's not good for SEO.

So let's remove this public from laravel project live URL.

Step One

Please go to root

rename `server.php` as `index.php`

 

Step Two

go to public folder and copy htaccess and paste it at -root. or make a new htaccess at root folder

after that, copy below code

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]

if you copied perfectly the paste it htaccess file.

Now type your domain and hit the enter, see it's perfectly working.

Thank You.

How to get Guzzle Post Request Response?

You can use it for get body response

Read More
            

How to combine two strings together in PHP 8

How to combine two strings together in PHP 8.

When we develop any application using PHP language, for deferent reason we need combine two string.

PHP 8 is recently release, this combine is also work at PHP 8.

Syntex:

<?php

$fullName = "Jahidul Hasan Zahid"; //string

Read More

Laravel 7 and password install common issue

Some developers make a simple mistake and get an error from Laravel 7 and password installation.

PROBLEM:
    - laravel/passport[v10.1.0, ..., 10.x-dev] require illuminate/auth ^8.2 -> found illuminate/auth[v8.2.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with an...

Read More