Yii2开启URI伪静态的相关配置
Yii2 开启URI伪静态的相关配置Yii2支持url伪静态链接转换在配置文件config/web.php中加入# config/web.php$config[components[// URI伪静态化配置urlManager[enablePrettyUrltrue,// 启用美化 URL隐藏 index.phpshowScriptNamefalse,// 不显示入口脚本名enableStrictParsingfalse,// 是否严格匹配规则false 时若无匹配则走默认suffix,// URL 后缀如 .htmlrules[// 路由规则定义],],],]服务启动方式开发时./yii serve启动后就能正常使用。生产环境部署nginx web 服务器虚拟机配置需要增加url rewrite配置项server{location /{#try_files $uri $uri/ /index.php?$args;if(!-f$request_filename){rewrite ^(.*)$ /index.php?s/$1last;}}}重启nginx服务即可用。