隐藏index.php
可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则。
Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了该文件),内容如下:
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
之前只能通过
http://localhost/oil2.1/index.php/index/main.html
进行访问;
在修改后,可以去掉index.php
http://localhost/oil2.1/index/main.html
参考链接:
链接地址