ThinkPHP路由使用Nginx
今天这两天服务器使用的Apache貌似不太稳,再加上服务器配置低,Nginx相对于Apache来说更轻量,并发更高,所以打算吧Apache换成Nginx
在服务器卸载Apache安装Nginx后,发现路由404,找到好多资料终于解决了,解决方法如下。
在ThinkPHP的public目录下,增加nginx.htaccess
文件,内容如下:
location / {
index index.html index.php;
if (!-e $request_filename) {
rewrite ^/dashboard$ /index.php/Home/Inoreader last;
rewrite ^/starred$ /index.php/Home/Inoreader last;
rewrite ^/logout$ /index.php/Home/Inoreader/logout last;
rewrite ^/discovery(.*)$ /index.php/Home/Inoreader last;
rewrite ^/all_articles$ /index.php/Home/Inoreader last;
rewrite ^/folder/(.*)$ /index.php/Home/Inoreader last;
rewrite ^/feed/(\d+)$ /index.php/Home/Inoreader last;
rewrite ^/article/(\w+)-(.*)$ /index.php/Home/Inoreader last;
rewrite ^/(.*)$ /index.php/$1 last;
}
}