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

Php 在laravel 5和WampServer中注册新用户时动态创建子域,php,apache,laravel,wamp,Php,Apache,Laravel,Wamp,我想在注册后根据每个用户在本地wampServer上的用户名为像tc.dev 我已经完成了在或其他类似的网络主题中提到的所有步骤 这是我添加到httpd vhosts.conf文件中的配置: <VirtualHost *:80> DocumentRoot "D:/wamp/www/tc/public/" ServerName tc.dev ServerAlias *.tc.dev <directory "D:/wamp/www/tc/public/"> O

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

我已经完成了在或其他类似的网络主题中提到的所有步骤

这是我添加到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>
这是我的路线:

Route::group(['domain' => '{account}.tc.dev'], function () {
        Route::get('/', function ($account, $id) {
            return view('main.pages.user.index');
        });
    });
tc.dev
工作正常,但我测试的任何子域都不工作,并且未显示
index
视图

什么是问题和解决方案

更新

根据,现在子域作为主域工作,但基于我编写的路径
main.pages.user.index
不显示,并且
DocumentRoot“D:/wamp/www/tc/public/”中的
index.php
文件显示


最后,经过多次研究,尝试了不同的解决方法。p> 使用之后,我必须为主域和子域使用两个不同的根

这适用于主域:

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

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

最近我对windows不太熟悉,因为我使用ubuntu和nginx,但我确实发现了这一点----您可能需要创建一个PAC文件…您不能在主机文件中使用通配符。但是,还有其他第三方软件可以创建自定义dns,并允许通配符。试试看。或者,您可以使用我几个月前编写的批处理脚本轻松地手动创建虚拟主机。如果您想尝试,这里是@MilanMaharjan的链接,我尝试了您的批处理脚本,主域(
tc.dev
)工作正常,但是像
test.tc.dev
这样的子域不工作,并给我
禁止的
错误。除了脚本之外,我还应该做额外的工作吗?您是否通过编辑脚本正确设置了主机和httpd vhost文件路径?能否检查虚拟主机条目是否已正确添加到vhosts文件?
Route::group(['domain' => '{subdomain}.tc.dev'], function()
{
    Route::any('/', function($subdomain)
    {
        return 'Subdomain ' . $subdomain;
    });
});