介绍
这篇文章给大家介绍怎么在Yii框架中配置路由,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
方法一:使用。htaccess
添加. htaccess文件,与索引。php同级
RewriteEngine #,if a  directory 或是a file 存在,use 从而request 直接 RewriteCond % {REQUEST_FILENAME} ! - f RewriteCond % {REQUEST_FILENAME} ! - d #,otherwise forward 从而request 用index . php RewriteRule 只索引。php
方法二:vhost
& lt; VirtualHost *: 80比; ,,ServerName public.oa.com ,,,DocumentRoot “D: \ phpStudy \ PHPTutorial \ WWW \ OA \前端\ web" ,,,& lt; Directory “D: \ phpStudy \ PHPTutorial \ WWW \ OA \前端\ web"比; ,,,,,#,use mod_rewrite for pretty URL 支持 ,,,,RewriteEngine ,,,,,#,If a directory 或是a file 存在,use 从而request 直接 ,,,,,RewriteCond % {REQUEST_FILENAME} ! - f ,,,,,RewriteCond % {REQUEST_FILENAME} ! - d ,,,,,#,Otherwise forward 从而request 用index . php ,,,,,RewriteRule 只index . php ,,,,,#,use index.php as index 文件 ,,,,,DirectoryIndex index . php ,,,,,#,……other 设置… ,,,,,#,Apache 2.4 ,,,,,Require all 理所当然 ,,,,,# #,Apache 2.2 ,,,,,#,Order 允许,拒绝 ,,,,,# Allow 得到所有 ,,,& lt;/Directory> & lt;/VirtualHost>
Yii配置
& # 39; urlManager& # 39;,=祝辞,( ,,,,,//美化路由 ,,,,,& # 39;enablePrettyUrl& # 39;,=祝辞,真的, ,,,,,//不启用严格解析 ,,,,,& # 39;enableStrictParsing& # 39;,=祝辞,假的, ,,,,,//index . php是否显示 ,,,,,& # 39;showScriptName& # 39;,=祝辞,假的, ,,,,,//伪静态化,seo ,,,,,& # 39;后缀# 39;,=祝辞,& # 39;. html # 39; ,,,,,//美化规则 ,,,,,& # 39;规则# 39;,=祝辞,( ,,,,,,,//第一条:文章详细页 ,,,,,,,& # 39;& lt;控制器:\ w +祝辞/& lt; id: \ d +祝辞& # 39;=祝辞& # 39;& lt; controller>/细节# 39; ,,,,,,,//第二条:文章列表页 ,,,,,,,& # 39;文章# 39;=祝辞& # 39;post/指数# 39; ,,,,,, ,,,,
关于怎么在Yii框架中配置路由就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。