zoukankan      html  css  js  c++  java
  • 【YII是个什么鬼】YII入门——URL Manager配置

    第一步:开启apache的rewrite模块

    (1)去掉LoadModule rewrite_module modules/mod_rewrite.so前面的注释
    (2)将<Directory "${SRVROOT}/htdocs">中的AllowOverride None设置为AllowOverride All
     
    第二步:设置YII项目中config目录下的web.php文件,在components参数中新增:
              'urlManager' => [
                'enablePrettyUrl' => true,
                'showScriptName' => false
               ], 
     
    第三步:在YII项目中的web目录下,新建文件.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
     
     
    以上三步,缺一不可。
     
    设置完以上,原始的URL如:basic/web/index.php?r=site/index,将对应为:basic/web/site/index
    如果想要更多自定义的效果,则设置urlManager中的rules参数。
  • 相关阅读:
    水滴二次开发日志5
    水滴二次开发日志4
    水滴二次开发日志3
    水滴二次开发日志2
    NOIp2020AFO记
    Diary(2020十一月 NOIP赛前集训)
    我们的Gary真的是太强辣
    Diary(2020十月 CSP赛前集训)
    Diary(2020九月 半集训)
    Music
  • 原文地址:https://www.cnblogs.com/anywing/p/4671581.html
Copyright © 2011-2022 走看看