How to create a subdomain in Laravel dynamically?

In my Windows / System32 / drivers / etc / hosts I have this:

127.0.0.1 localhost 127.0.0.1 site.dev 127.0.0.1 *.site.dev 

In my xampp / apache / conf / extra / httpd-vhost I have this:

 <VirtualHost site.dev> DocumentRoot "C:/xampp_7/htdocs/" <Directory "C:/xampp_7/htdocs/"> </Directory> </VirtualHost> <VirtualHost *.site.dev> DocumentRoot "C:/xampp_7/htdocs/" <Directory "C:/xampp_7/htdocs/"> </Directory> </VirtualHost> 

Now, if I am going to run http://site.dev/project/public , it works. I have a route command:

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

If I open http://sub.site.dev/startscript/public/ , I get the error "This site could not be reached."

The function of the program is that it can create subdirectories. For example, I have a business website. I can access / create like this.

 inventory.mybusiness.com sales.mybusiness.com ad.mybusiness.com 
+7
php apache subdomain laravel hosts
source share
1 answer

I solved it. I used Acirlic DNS Proxy from this answer. Place an order below, you will find the answer.

https://laracasts.com/discuss/channels/general-discussion/dynamic-sub-domain-creation-on-new-user-registration-in-laravel-5-and-wampserver

then

 Route::group(['domain' => '{account}.dns.dev'], function () { Route::get('/', function ($account) { return $account; }); }); 

it works now.

+5
source share

All Articles