上面介绍的是 thinkphp url 的访问方式,按照上面的访问方式配置nginx服务器配置,如下所示:
server { listen 8090; server_name localhost 172.26.62.185; root /Users/staff/Documents/study/tp5;(注:这里是 thinkphp 的根目录,所以访问地址是:http://localhost:8090/public/index.php/index/index/index) (如果这里的root /Users/staff/Documents/study/tp5/public; 那么访问地址http://localhost:8090/index.php/index/index/index) index index.php; location / { try_files $uri @rewrite; } location @rewrite { set $static 0; if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) { set $static 1; } if ($static = 0) { rewrite ^/(.*)$ /index.php?s=/$1; } } location ~ /Uploads/.*\.php$ { deny all; } location ~ \.php/ { if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_NAME $1; fastcgi_param PATH_INFO $2; fastcgi_param SCRIPT_FILENAME $document_root$1; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
参考:
http://www.thinkphp.cn/topic/34380.html