一,找到/public/.htaccess文件,如果你的入口文件已经移动到根目录下,那么你的.htaccess文件也要剪切到根目录下,总之要确保.htaccess跟入口的index.php保持同级。
二,根据你的php环境分别设置.htaccess文件:
Apache:

1<IfModule mod_rewrite.c> 2Options +FollowSymlinks -Multiviews 3RewriteEngine on 4RewriteCond %{REQUEST_FILENAME} !-d 5RewriteCond %{REQUEST_FILENAME} !-f 6RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 7</IfModule>

phpstudy:

1<IfModule mod_rewrite.c> 2Options +FollowSymlinks -Multiviews 3RewriteEngine on 4RewriteCond %{REQUEST_FILENAME} !-d 5RewriteCond %{REQUEST_FILENAME} !-f 6RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1] 7</IfModule>

Nginx(在Nginx.conf中添加):

1location / { // …..省略部分代码 2 if (!-e $request_filename) { 3 rewrite ^(.*)$ /index.php?s=/$1 last; 4 break; 5 } 6}