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;
}
}