Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

beli0135's avatar

.htaccess 404

Laravel 9: I am having 404 error when I try to access my dev site at hostgator. I have DOCUMENT_ROOT point to public folder of laravel: dev.mysite.com/public in there, I copied exactly from this site https://github.com/laravel/laravel/blob/9.x/public/.htaccess which is:

<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>

Do I need to have .htaccess also in root directory? If so, how it should be made? I tried many combinations but I either get error 500 or 404. I also tried to put DOCUMENT_ROOT in Laravel directory and add .htaccess that points to /public to no avail. What I am missing?

0 likes
2 replies
Snapey's avatar

Do you get a laravel 404 or apache 404?

create a simple html file in the public folder and access it with your browser. Does it load or 404

beli0135's avatar

@Snapey I created test.html in /public folder and accessed it directly with no issues. Though when I tried index.php it gave me 404

Please or to participate in this conversation.