網(wǎng)上講了很多方法,試了都有問題,最后用這個可以了:
https://www.php.cn/blog/detail/35221.html
偽靜態(tài)就是在訪問url時隱藏index.php
例:
http://domain.com/index.php/admins/login/login
變成:
http://domain.com/admins/login/login
nginx
- 根目錄下新建
.rewrite.conf文件
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
Apache
- 根目錄新建文件
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
</IfModule>