问题
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 is working. I have this route command:
Route::group(['domain' => '{subdomain}.site.dev'], function($subdomain) {
return $subdomain;
});
If I open http://sub.site.dev/startscript/public/ , I get an error of "This site can’t be reached".
The function of the program is that it can create subdirectories. Example, I have a business website. I can access/create like this.
inventory.mybusiness.com
sales.mybusiness.com
ad.mybusiness.com
回答1:
I have solved it. I used Acyrlic DNS Proxy from this answer. Checkout the below link 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 the
Route::group(['domain' => '{account}.dns.dev'], function () {
Route::get('/', function ($account) {
return $account;
});
});
is now working.
来源:https://stackoverflow.com/questions/40804235/how-to-create-subdomain-in-laravel-dynamically