Home » Php » php – laravel api subdomain mapping

php – laravel api subdomain mapping

Posted by: admin July 12, 2020 Leave a comment

Route::group(array('domain' => 'api.domain.com'), function()
    Route::get('/','[email protected]');
    Route::get('/gettweets','[email protected]');
    Route::get('/viewtweets','[email protected]');
    Route::get('/viewvideos','[email protected]');

This is my routes.php

I am calling this /gettweets route but it says /gettweets is not found on server. Using godaddy linux shared.
I am only able to call / requests.
How can I make laravel read this routes.

How to&Answers:
  1. Mod_rewrite must be enabled on your server. Check this post

  2. Check you .htaccess file in public folder (which your domain pointed to) and it should contain below

    Options -MultiViews

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

Create a .htaccess file under the public directory if it does not exists.

If this does not work leave a comment.


You need to specify godaddy to read wildcards in a way that any subdomain points to the same point. Doing that you will manage subdomains with your laravel app