- 三大路由
一、普通模式
'url_route_on' => false,
路由关闭后,不会解析任何路由规则,采用默认的PATH_INFO
模式访问URL
二、混合模式
开启路由,并使用路由定义+默认PATH_INFO
方式的混合
'url_route_on' => true,
'url_route_must'=> false,
三、强制模式
开启路由,并设置必须定义路由才能访问:
'url_route_on' => true,
'url_route_must' => true,
2.
3.
4.
5.
6.
7.隐藏入口文件index.php
隐藏入口文件
在ThinkPHP5.0中,出于优化的URL访问原则,还支持通过URL重写隐藏入口文件,下面以Apache
为例说明隐藏应用入口文件index.php的设置。
下面是Apache的配置过程,可以参考下:
1、httpd.conf
配置文件中加载了mod_rewrite.so
模块
2、httpd-vhost.conf文件AllowOverride None
将None
改为 All
3、在应用入口文件同级目录添加.htaccess
文件,内容如下:
<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>