Home > Net >  I want to host laravel 9 project on cpanel but getting 404 not found
I want to host laravel 9 project on cpanel but getting 404 not found

Time:10-17

I have been trying for 3 days still didn't find any solution of it. I have tried so many solution still remained same.

Here is my .htaccess:

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

    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]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Here my laravel project is in the public_html. I am sharing a screenshot so that you guys can figure out the issue.

enter image description here

Here is the live of my website: https://kothay-jaben.com/

CodePudding user response:

To deploy your laravel project, you should leav the directory structure intact. So, the project should not be inside public_html. Upload all files adn directories one level up (out side public_html). Then do one of the follwoing:

  1. copy/move files from public to public_html
  2. Make a symlink from public_html

CodePudding user response:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

<Files .env>
Order allow,deny
Deny from all
</Files>
  • Related