Laravel without public in CPanel - How

Submitted by lwinmaungmaung on
Laravel without public - Image by StockSnap from Pixabay

Laravel is one of the most famous PHP Framework in community and widely used by millions of websites. One more thing, many people want to save the cost by using Laravel in shared hosting because our hosting is about 40 USD per year. How can anyone resist? You also see some websites are come with Laravel without public folder trailing slash. But one thing is...

Your URL is /public.. YES. Your url is https://www.blahblah.com/public.  How horrible. So, how to remove and set as https://www.blahblah.com. Laravel without public folder trailing slash is mandatory to our issue.

OK, here is a tip.

Laravel without Public

Laravel without public - Image by 192635 from Pixabay

Our hosting is using Apache and you can easily remove /public folder in your system. Let me show you.

You have to Go to File Management under CPanel.

After opening File Manager and you have to check to see the hidden files.

You will see the .htaccess file under your public_html/your_project/public.

move .htaccess file under /public_html/your_project.

Edit the .htaccess and you will see the file information as follows:

<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>

        Options -MultiViews

    </IfModule>

 

    RewriteEngine On

 

    # Redirect Trailing Slashes If Not A Folder...

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_URI} (.+)/$

    RewriteRule ^ %1 [L,R=301]

 

    # Handle Front Controller...

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^ index.php [L]

 

    # Handle Authorization Header

    RewriteCond %{HTTP:Authorization} .

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

</IfModule>

Edit this line will solve.

RewriteRule ^ public/index.php

After saving your .htaccess file. You will refresh your website without public and you will see that your website without /public is now accessible. Viola.

If you want some information more about shared hosting, There are CPanel Advantages.

If you want Cheap hosting with effective outcome, Visit Our Website.