laravel 5 和 WampServer 中新用户注册时动态创建子域

Dynamic sub-domain creation on new User registration in laravel 5 and WampServer

我想在注册后根据她在本地 wampServer 上的用户名为 tc.dev

这样的域分配一个特定的子域

我已经完成了 This Topic 或网络上其他类似主题中所述的所有步骤。

这是我添加到 httpd-vhosts.conf 文件的配置:

    <VirtualHost *:80>
DocumentRoot "D:/wamp/www/tc/public/"
ServerName tc.dev
ServerAlias *.tc.dev
<directory "D:/wamp/www/tc/public/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from all
</directory>
</VirtualHost>

这是我添加到 C:\Windows\System32\Drivers\etc\hosts 文件中的内容:

127.0.0.1   tc.dev  
127.0.0.1   *.tc.dev

这是我的路线:

Route::group(['domain' => '{account}.tc.dev'], function () {
        Route::get('/', function ($account, $id) {
            return view('main.pages.user.index');
        });
    });

tc.dev 工作正常,但我测试的任何子域都不起作用,index 视图未显示。

什么是问题和解决方案?

更新:

根据 Wildcards in a Windows hosts file ,现在子域作为主域但是基于我写的路由 main.pages.user.index 不显示并且 index.php 文件在 DocumentRoot "D:/wamp/www/tc/public/" 是显示。

这条路线不考虑接缝。

经过多次研究和尝试不同的方法,我终于可以解决问题。

使用Acrylic DNS Proxy后,我必须为主域和子域使用两个不同的根。

这对于主域:

// Match my own domain
Route::group(['domain' => 'tc.dev'], function()
    {
    Route::any('/', function()
    {
        return 'My own domain';
    }); 
}); 

另一个用于处理子域:

Route::group(['domain' => '{subdomain}.tc.dev'], function()
{
    Route::any('/', function($subdomain)
    {
        return 'Subdomain ' . $subdomain;
    });
});

其实最主要的是我必须使用另一个Route来控制作用于主域的路由而我被忽略了。