Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel api subdomain mapping

Route::group(array('domain' => 'api.domain.com'), function()
{
    Route::get('/','TwitterController@index');
    Route::get('/gettweets','TwitterController@getTweets');
    Route::get('/viewtweets','TwitterController@viewTweets');
    Route::get('/viewvideos','TwitterController@viewVideos');
});

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.

like image 338
Aniket Karne Avatar asked Dec 07 '16 17:12

Aniket Karne


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

like image 95
Praneeth Nidarshan Avatar answered Nov 15 '22 06:11

Praneeth Nidarshan