第一步:配置 URL Management(网址管理)

只需要在config文件夹下面的main.php文件中进行配置就好了

到配置文件中开启:

LoadModule rewrite_module modules/mod_rewrite.so

'components' => array(
    'urlManager' => [
      'showScriptName' => false,//这里是隐藏index.php那个路径的
      'urlFormat' => 'path',
      'rules' => [
        '<controller:\w+>/<id:\d+>' => '<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
        '<controller:\w+>/<action:\w+>' => '<controller>/<action>'
      ]
    ],
    'user' => array(
      
      // enable cookie-based authentication
      'allowAutoLogin' => true
    ),<span style="font-family: Arial, Helvetica, sans-serif;">)</span>

第二步:进行apache配置

yii中有个文件:.htaccess 用来专门配置apache服务器的,这个文件下面配置输入下面的代码

<IfModule mod_rewrite.c>
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
</IfModule>

这个文件配置好了之后,一定要把apache中的rewrite模块开启:

Yii 1.0 伪静态即Yii配置Url重写(转)

然后就OK了。

整个URL的配置就已经完成了。

相关文章:

  • 2022-12-23
  • 2022-01-16
  • 2021-08-16
  • 2022-02-14
  • 2021-10-27
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-01-09
  • 2021-10-19
  • 2021-09-28
  • 2022-12-23
相关资源
相似解决方案