ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
1\. 需要开启Apache的rewrite模块 2\. 同时修改虚拟主机的 AllowOverride 的值为 All 3\. 同时在public目录创建.htaccess文件 TP官方默认的 .htaccess文件 <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,规则如下: <IfModule mod\_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST\_FILENAME} !-d RewriteCond %{REQUEST\_FILENAME} !-f RewriteRule ^(.\*)$ index.php \[L,E=PATH\_INFO:$1\] </IfModule> 如果你使用的apache版本使用上面的方式无法正常隐藏index.php,可以尝试使用下面的方式配置.htaccess文件 <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> 如果用的nginx,在Nginx.conf中配置规则如下: location / { if (!-e $request\_filename) { rewrite ^(.\*)$ /index.php?s=/$1 last; break; } }