skip to Main Content

I am trying to deploy my Laravel 8 app to a folder in CPANEL (first time I’ve deployed Laravel). I have searched the forum and made changes as the many posts direct. I am getting 404 errors across all pages apart from the homepage and login and register pages. This is a common error but I cant find a solution. Dont shoot me.

1.All files uploaded to url/laravel/blog

  1. Public folder moved outside and renamed public_html
  2. The /laravel folder now has two directories /blog and /public_html
  3. index.php in the public_html folder updated:

require DIR.’/../blog/vendor/autoload.php’;

$app = require_once DIR.’/../blog/bootstrap/app.php’;

  1. New .htaccess file added to the root of the public_html and set to chmod 755 (detailed below)
  2. Renamed the cache folder in the /bootstrap folder so that new cache is created (I hope)
  3. Database is linked within the .env file

I am out of ideas, I have created a test html file in the public folder and I can see this in the browser when I navigate to it. I am learning and any help will be appreciated.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    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>

2

Answers


  1. Chosen as BEST ANSWER

    I needed to point the subdomain/add-on domain to the public folder. No need to move anything or change Htaccess etc.... Credit to https://stackoverflow.com/users/2325620/james-clark-developer


  2. Try this in your .htaccess

    DirectoryIndex index.php
    <IfModule mod_rewrite.c>
    
        RewriteEngine On
        RewriteBase /
    
        RewriteRule ^$ public/index.php [L]
    
        RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
    
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search