隐藏入口文件index.php
apache
- httpd.conf配置文件中加载了mod_rewrite.so模块
- vhosts.conf里的AllowOverride None 将None改为 All
- 把下面的内容保存为.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>
原来的.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>
两个对比的话,你会发现index.php后面少了一个问号。
模板参数配置
application/config.php:
'template' => [
// 模板引擎类型 支持 php think 支持扩展
'type' => 'Think',
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写
'auto_rule' => 1,
// 模板路径
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => DS,
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '<',
// 标签库标签结束标记
'taglib_end' => '>',
// 静态文件路径替换
'tpl_replace_string' => [
'__ADMIN__' => '/static/Admin',
'__Home__' => '/static/Home',
'__Wap__' => '/static/Wap',
'__Api__' => '/static/Api'
]
]
模板静态文件路径的使用
<link rel="stylesheet" type="text/css" href="__ADMIN__/page.css">