how to setup url friendly in yii framework automatically (如何在 yii 框架中自动设置 url 友好)
问题描述
我刚刚学习了 yii 框架并阅读了本教程关于 yii 如何设置 url
I just learning yii framework and read this tutorial about yii how to setup url
但我不知道,假设我有 10 个控制器,我应该在配置文件中一个一个地定义控制器吗?有没有更好的方法来为所有控制器设置 url 友好,例如 www.yoursite.com/yourController/yourAction/yourID?
but I have no idea, suppose i have 10 controllers, should I define one by one controllers in the config file ? is there a better way to setup url friendly like www.yoursite.com/yourController/yourAction/yourID for all controller ?
我认为 codeigniter 是自动完成的...... yii 怎么样?
I think codeigniter did that automatically ... how about yii ?
推荐答案
在/protected/config/main.php 添加..
In /protected/config/main.php add..
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
),
),
在您的网络根目录中添加一个 .htaccess..
In your web root an .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
这篇关于如何在 yii 框架中自动设置 url 友好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 yii 框架中自动设置 url 友好
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
