laravel5.4的nginx配置子域名该如何实现?
环境ubuntu14.04,nginx1.12.1,laravel5.4,web.php配置如下:
Route::group(['domain' => 'admin.happy.co'], function (){
return 123;
});
Route::group(['domain' => 'happy.co'], function (){
Route::get('/', function () {
return 333;
});
});
nginx配置如下:
server {
listen 80 ;
root /code/HappyCoding/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name ~^(.+)?\.happy\.co$;
location / {
try_files $uri $uri/ /index.php?$query_string;
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
autoindex_localtime on;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
}
其中server_name设置为 happy.co admin.happy.co的话,happy.co可以正常路由,admin子域名提示Sorry, the page you are looking for could not be found.
如果server_name设置为 *.happy.co的话,则都路由不到.
求大神指点laravel的二级域名该如何配置!
1 Comment
@leedomzhang#1288
你这里没有定义任何路由当然找不到了