For example, local virtual primary domain name: www.learn-laravel.com, to support sub-domain names, first change the apache httpd-vhost.conf configuration, as follows:
<VirtualHost *: 80>
DocumentRoot "/xampp/htdocs/laravelCMS/public /"
ServerName www.learn-laravel.com
ServerAlias * .learn-laravel.com
ErrorLog "logs/www.learn-laravel.com-error. log"
CustomLog "logs/www.learn-laravel.com-access. log" combined
</VirtualHost>
And bind the primary domain name and sub-domain name host to the local machine.
127.0.0.1 www.learn-laravel.com
127.0.0.1 tanteng.learn-laravel.com
Here we demonstrate adding a tanteng.learn-laravel.com subdomain in Laravel5.
Next, you only need to configure the sub-domain name in one step, which is very convenient.
Add the sub-domain routing configuration in routes. php of Laravel5, for example, file location: D: \ xampp \ htdocs \ laravelCMS \ app \ Http \ routes. php
$ Router-> group (['domain '=> 'tanteng .learn-laravel.com'], function ()
{
Route: get ('/', function ()
{
Echo 'Hello, world! ';
});
Route: get ('/test', function ()
{
Echo 'test ';
});
});
Access the tanteng.learn-laravel.com directly to display "hello, world !".
Access tanteng.learn-laravel.com/testto display testtesttest ".