转自http://www.javashuo.com/article/p-xndazpmg-ex.htmlphp
能够经过 http://www.mracale.com/项目名/模块名/方法名 进行访问css
首先,你要确保在不配置二级目录的状况下,能够经过浏览器访问到。例如:http://www.mracale.com/blog/index.php?s=index/index/indexhtml
若是不能正常访问,报404错误,建议看一看你的nginx配置中是如何处理php的。由于ThinkPHP中index.php并不必定都是在URL中末尾出现的,因此要使用nginx
location ~ .php($|/)
而不是浏览器
location ~ .php$
例如以下配置:php7
location ~ \.php($|/) { root /home/html; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
进行URL重写,将默认访问URL中的index.php?s=经过rewrite隐藏spa
location /blog/ { index index.php index.html index.htm; if (!-e $request_filename){ rewrite ^/blog/(.*)$ /blog/index.php?s=$1 last; } }
这样就能够经过 http://www.mracale.com/blog/index/index/index 来进行访问了。.net
其实nginx的二级目录配置都是同样的套路,这里也能够参考之前写过的另外一篇配置记录:nginx配置phalconunix
有的小伙伴配置后出现访问资源文件报错模块不存在错误,这里只需添加对静态资源文件的特殊处理便可,例如:code
location ~ .*\.(css|js|gif|jpg|jpeg|png|bmp|swf)$ { root /home/html; expires 30d; }