搞了半天,尝试使用配置pathinfo类型的url,发现不支持,只支持普通的方式
http://blog.duicode.com/index.php?s=/index/index
但是pathinfo是有好处的
1.它提供了最好的SEO支持
2.可以实现 URL 的伪静态
3.它看起来更简洁、更好看
比如上面的url就可以变成
http://blog.duicode.com/index.php/index/index
于是乎就去配置nginx
server {
listen 80;
server_name sui.com;
root /tmmee/sad.cn/public;
index index.php index.html index.htm;
location ~* ^.+.(jpg|jpeg|gif|css|png|js|thumb) {
expires 30d;
}
location / {
try_files $uri @default;
}
#注意这里 之前我配置的只有$,不支持也有这个问题,请改为($|/)
location ~ \.php($|/) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
}
但是还要隐藏index.php入口文件,其实就是做个重定向就好了,添加上下面一段
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}