1.web环境是Apache的话找到目录public的.hatccess文件、加入代码,规定url重写规则
<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>
2.使用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>
3.web环境是nginx的话需要修改配置文件
location / { // …..省略部分代码
if (!-e request_filename) {
rewrite ^(.*)
request_filename) { rewrite ^(.*)
/index.php?s=/$1 last;
break;
}
}