URL 部分
-PATHINFO设置
框架默认路由 www.aa.com/index.php?r=site/index
config/web.php
'urlManager' => [
'enablePrettyUrl' => true,//默认是false,设置为true时,才是pathinfo格式路由,但是带index.php入口文件,如果需要隐藏需要配合.htaccess文件
'showScriptName' => false,
'rules' => [
],
],
public/目录下,.htaccess 文件
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
设置成功后的路由:www.aa.com/site/index
- 对于一些刚使用Yii2的同学可能刚下载advanced 版 在frontend/web/ 下找不到index.php
解决: 在advanced目录下有个 init.bat 文件 双击运行,会出现一个dos窗口 输入 0(开发模式) 或 1(产品模式) 按回车 再输入 yes 回车 这样就能生成入口文件了.

8991

被折叠的 条评论
为什么被折叠?



