用户名为子域 - MAMP - Laravel 4.0

时间:2013-07-29 11:20:11

标签: apache .htaccess subdomain laravel-4 mamp

我在Laravel 4.0项目中工作,我是Laravel框架的新手。我正在使用laravel开发一个多租户应用程序,我将使用'UserName'作为子域。如果用户浏览其指定的子域,他们将看到自定义信息和页面。

例如,有人浏览xyz.myapp.com,他们会看到为用户的客户开发的自定义页面。

为了让子域工作,我使用了以下的laravel代码。

Route::group(array('domain' => '{account}.myapp.com'), function()
{

    Route::get('user/{id}', function($account, $id)
    {
        return view::make('profile')
    });

});

然而,当我试图访问xyz.myapp.com时,我收到以下错误:

Server not found

          Firefox can't find the server at xyz.myapp.com.

我想我需要在MAMP中做一些技巧。我已经搜索了很多天来在MAMP环境中动态启用子域,但我运气不好。请帮忙!!!

2 个答案:

答案 0 :(得分:2)

您可以使用此Apache2文档:http://httpd.apache.org/docs/2.2/en/vhosts/mass.html来了解如何在子域上使用URL重写。

答案 1 :(得分:0)

关于多子域的本教程适用于Codeigniter框架,但服务器配置应该相同。

http://net.tutsplus.com/tutorials/php/basecamp-style-subdomains-with-codeigniter/