配置 nginx 虚拟主机
- 原因
为了解决主页可以访问但是路由没有效果的情况 -
vhost.conf 代码
server { listen 80; server_name local.ladmin.com local.ladmin.com; root "D:/items/laravel/lesson-admin/public"; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?$query_string; #autoindex on; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "POST, GET, OPTIONS"; add_header Access-Control-Allow-Credentials "true"; add_header Access-Control-Allow-Headers "Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With"; if ($request_method = 'OPTIONS'){ return 204; } } }
推荐文章: