1.在Nginx中開啓rewrite
server {
listen 80;
server_name new.com ;
location / {
root F:/www/new/web;
index index.html index.htm index.php;
#autoindex on;
if (!-e $request_filename){
rewrite ^/(.*) /index.php?r=$1 last;
}
}
location ~ \.php$ {
root F:/www/new/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
2.config中web.php 配置
'urlManager' => [
'enablePrettyUrl' => true, //美化url==ture
'enableStrictParsing' => false, //不啓用嚴格解析
'showScriptName' => false, //隱藏index.php
'rules' => [
'<module:\w+>/<controller:\w+>/<id:\d+>' => '<module>/<controller>/view',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
],
]
Yii2的urlManager URL美化
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Yii 超全局數組常用操作方法
zhuzhenyu307
2018-08-27 03:59:00
Yii框架學習筆記(第一天)-執行流程
好大油肚
2018-08-27 03:24:04
Yii框架學習第二天-執行流程
好大油肚
2018-08-27 03:24:04
Yii學習第三天-Event
好大油肚
2018-08-27 03:23:39
Yii CActiveModel filter 搜索
千点距
2018-08-26 21:43:22
對yii2 內置的behavior理解(TimestampBehavior篇)
zhoupenghui168
2018-08-26 17:39:12
對yii2 內置的behavior理解(BlameableBehavior篇)
zhoupenghui168
2018-08-26 17:39:12
對yii2 擴展behavior理解(PinyinBehavior篇)
zhoupenghui168
2018-08-26 17:39:10
yii2 event實例(基於restful風格)
zhoupenghui168
2018-08-26 17:39:08
MVC--深入理解YII2
zhoupenghui168
2018-08-26 17:39:04
Yii 1.x IOS推送
j335150925
2018-08-26 17:27:18
yii1.1.x學習筆記(3)緩存
j335150925
2018-08-26 17:27:18
yii1.1.x學習筆記(1)數據庫操作
j335150925
2018-08-26 17:27:17
yii1.x學習筆記(4)好用的數據庫操作
j335150925
2018-08-26 17:26:59