dimanche 1 avril 2018

Why Laravel is showing 404 error on all API routes for subdomain?

My application is based on two subdomains. They are dashboard.myapplication.com and api.myapplication.com. Dashboard part of my application is working fine, and it is not showing 404 not found error on any route.

But when I try to access /test on my api.myapplication.com, it is showing me 404 not found error which is kind of weird because by .htaccess file exist public directory and my virtual host in apache contains AllowOverride All as well as routes on my dashboard are working fine.

Here is my api.php which contains / route which is working fine and also /test route which is showing 404 not found error.

Route::group(['domain' => Config::get('app.api_domain'),'middleware' => 'auth:api'], function () {
    Route::get("/", function () {
        return "Welcome to API";
    });

    Route::get('test',function(){
        return "Hello!";
    });
});

I've double-checked, and I know that app.php contains api_domain and that's why I can access api.myapplication.com. I don't know if it's .htaccess issue or not. I don't think it's .htaccess issue because Laravel should handle these request out of the box.

UPDATE (My .htaccess file):

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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2uFpuv5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire