gpt4 book ai didi

php - 如何在 yii 框架中自动设置 url 友好

转载 作者:可可西里 更新时间:2023-11-01 12:44:09 27 4
gpt4 key购买 nike

我刚刚学习 yii 框架并阅读了本教程关于yii how to setup url

但我不知道,假设我有 10 个 Controller ,我应该在配置文件中一个一个地定义 Controller 吗?有没有更好的方法来为所有 Controller 设置友好的 url,例如 www.yoursite.com/yourController/yourAction/yourID?

我认为 codeigniter 会自动完成……yii 怎么样?

最佳答案

在/protected/config/main.php 添加..

    'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
),
),

在您的网络根目录中有一个 .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

关于php - 如何在 yii 框架中自动设置 url 友好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1189823/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com