[TOC] #### ThinkPHP 5.0 --- `public/.htaccess` 文件內(nèi)容 ```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 (框架默認(rèn)自帶的)** ```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 服務(wù)器,那么需要在運(yùn)行目錄下的 `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** ![](https://img.itqaq.com/art/content/b98b48d13781a5981879970b1b3d421a.jpg)