[TOC] #### ThinkPHP 5.0 --- `public/.htaccess` 文件内容 ```html <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule> ``` #### ThinkPHP 6.0 --- TP6.0 官方文档:[https://www.kancloud.cn/manual/thinkphp6_0/1037488](https://www.kancloud.cn/manual/thinkphp6_0/1037488) **Apache (框架默认自带的)** ```html <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule> ``` ##### Apache **在 PhpStudy 中的 Apache Url重写文件需要在 index.php 后加 `?`** ```html <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L] </IfModule> ``` **如果 PhpStudy 使用 Nginx 作为 Web 服务器,那么需要在运行目录下的 `nginx.htaccess` 中添加下面配置** ``` location / { index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } #autoindex on; } ``` ##### Nginx **宝塔面板 Nginx** 