laravel api 子域映射

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');
});

这是我的routes.php

我正在调用此 /gettweets 路由,但它说 /gettweets 在服务器上找不到。使用 godaddy linux 共享。 我只能调用 / 个请求。 我怎样才能让 laravel 读取这条路线。

您需要指定 godaddy 以任何子域指向同一点的方式读取通配符。这样做,您将使用 laravel 应用程序

管理子域

https://mx.godaddy.com/help/setting-up-wildcard-dns-3301

  1. Mod_rewrite 必须在您的服务器上启用。 Check this post

  2. 检查 public 文件夹(您的域指向的文件夹)中的 .htaccess 文件,它应该包含以下内容

    选项 - 多视图

    RewriteEngine On
    
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ / [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}]
    

在public目录下创建一个.htaccess文件如果不存在

如果这不起作用请发表评论。