>  기사  >  PHP 프레임워크  >  yii 프레임워크에서 라우팅을 구성하는 방법

yii 프레임워크에서 라우팅을 구성하는 방법

王林
王林원래의
2020-02-18 10:47:513149검색

yii 프레임워크에서 라우팅을 구성하는 방법

먼저 서버 구성(httpd.conf)에서 다시 쓰기 모듈을 활성화합니다.

#开启重写模块,将其前面的#去掉
LoadModule rewrite_module modules/mod_rewrite.so
#Directory中允许覆盖开启
<Directory "${SRVROOT}/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn&#39;t give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

(권장 튜토리얼: yii 프레임워크)

서버 구성 파일 추가 .htaccess

RewriteEngine on

###############################
# @email test@test.com
# @author test
###############################

#重写规则
#如果是一个目录或者文件,就访问目录或者文件
RewriteCond %{REQUEST_FILENAME} !-d

#如果文件存在,就直接访问文件,不进行下面的RewriteRule
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule . index.php

프레임워크 구성 항목에 urlManager 구성 항목 추가 frontendconfigmain.php

&#39;urlManager&#39; => [
    &#39;enablePrettyUrl&#39; => true,
    &#39;showScriptName&#39; => false,
        //&#39;suffix&#39; => &#39;.html&#39;,//URL后缀],
# 🎜 🎜#더 많은 프로그래밍 관련 내용은 php中文网

programming tutorial 칼럼을 주목해주세요!

위 내용은 yii 프레임워크에서 라우팅을 구성하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.