Iamceo's avatar
Level 1

getting 403 error in search console for laravel 11 website

I have website which has 600k posts. When I submitted website to google search console, Some of posts getting 403 error. Here I am using laravel page cache package .htaccess file

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

    # Serve Cached Page If Available...
    RewriteCond %{REQUEST_URI} ^/?$
    RewriteCond %{DOCUMENT_ROOT}/page-cache/pc__index__pc.html -f
    RewriteRule .? page-cache/pc__index__pc.html [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.html -f
    RewriteRule . page-cache%{REQUEST_URI}.html [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.json -f
    RewriteRule . page-cache%{REQUEST_URI}.json [L]
    RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.xml -f
    RewriteRule . page-cache%{REQUEST_URI}.xml [L]

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

all 600k posts can be access through single route with related slug. route.php

Route::middleware('page-cache')->group(function () {
    .
	.
    Route::get('/{slug}', [HomeController::class, 'handleRequest']);
   .
});

I am using hostinger hosting.

0 likes
2 replies
Tray2's avatar

403 means forbidden, and my guess is that there is some kind of throttling done in your setup that generates a 403. 600K of requests will sooner or later overload and generate an error and 403 might be one of them errors.

Iamceo's avatar
Level 1

@Tray2 Thank you for reply. Here I found, when 403 error occurs its generate response in 1ms while 404 or other errors takes 25ms to 40ms (I found this data from Hostinger performance analytics). May be It is server level error which hit before going to laravel app. (.htaccess file is responsible for this error because page-cache middlewere generate static html file within folder public_html->page-cache)

Please or to participate in this conversation.