yii2美化URL路径
1、http://www.yiichina.com/download进入下载bacis的压缩包,放到项目里面;
2、在访问页面的话需要在---------在目录下bacis--->config----->web.php配置文件中加入
在components=>[中放入以下
//实现pathinfo的形式访问的配置方法-----http://www.jb51.net/article/82019.htm //如果是apache,在入口文件(index.php)所在的目录下新建一个文本文件,接着另存为.htaccess,用记事本打开此文件加入: 'urlManager' => [ 'enablePrettyUrl' => true,//去除"?r=" 'showScriptName' => false,//该属性确定是否应将条目脚本包含在创建的URL中 'enableStrictParsing' => false,//该enablePrettyUrl属性是强制性的,因为它会切换相当URL格式 'rules' => [ ], ],
]
3、去掉index.php参考以下操作:
1).如果是apache,在入口文件(index.php)所在的目录下新建一个文本文件,接着另存为.htaccess,用记事本打开此文件加入:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php
保存即可。
2)
如果是nginx,在nginx配置文件中加入:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
server {
listen 80;
server_name localhost;
location / {
root E:/wwwroot/yii2.0;
index index.html index.php;
if
(!-e
$request_filename
){
rewrite ^/(.*) /index.php last;
}
}
location ~ \.php$ {
root E:/wwwroot/yii2.0;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root
$fastcgi_script_name
;
include
fastcgi_params;
}
}
|
4)重启web服务器。
至此,配置完毕。
5、yii2 框架使用gii工具创建模块参考链接http://blog.csdn.net/qq_37920939/article/details/79482949