我也不知道为什么要叫伪静态,领悟不够深刻。作用是 访问时url可以少写个 index.php。
弊端也存在,入口不是唯一的话,比如是index2.php 此时你要是还想隐藏index2.php的话
实现方案:
1.在index.php中这个唯一入口检索index2.php,从而 匹配到时 进行再一步隐藏,有种自欺欺人的感觉
2.在index.php入口中检索所有功能,不存在则跳转 第二入口 再进行url隐藏
Nginx1.15.11
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
Apache2.4
<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>