【thinkphp】之配置虚拟域名
第一步:
电脑C盘C:\Windows\System32\drivers\etc\hosts
127.0.0.1 www.shop.com
第二步:
找到你的phpstudy安装目录,C:\phpStudy\PHPTutorial\nginx\conf\nginx.conf
server {
listen 80;
server_name www.shop.com;
client_max_body_size 1000M;
root "C:/phpStudy/PHPTutorial/WWW/shop/public/";
location / {
index index.html index.htm index.php l.php;
autoindex off;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
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;
}
}
[ Nginx ]
在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:
location / { // …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
是nginx重写,必须配置,不然打不开
第三步:
配置完,重启nginx
装逼成功!!!