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

AJTHEGR8's avatar

Getting 404 on valid subdomain pages when refreshing on laravel

I have a subdomain and when i try to refresh page frequently it redirect me to 404 page or when my Ajax calls made some got 200 and some got 404 and if i refresh again then it works.

env APP_HOST="example.com"

route service provider

$this->routes(function () {

        Route::domain('portal.' . env('APP_HOST'))
        ->middleware('web')
        ->namespace($this->namespace)
        ->group(base_path('routes/portal/clients.php'));

        Route::domain('logistics.' . env('APP_HOST'))
        ->middleware('web')
        ->namespace($this->namespace)
        ->group(base_path('routes/logistic.php'));

        Route::middleware('api')
            ->prefix('api')
            ->group(base_path('routes/api.php'));

        Route::domain(env('APP_HOST'))
            ->middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/web.php'));

    });

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

<VirtualHost *:80> DocumentRoot "${ROOT}" ServerName ${SITE} ServerAlias *.${SITE} <Directory "${ROOT}"> Options indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>

0 likes
0 replies

Please or to participate in this conversation.