您好,登錄后才能下訂單哦!
小編給大家分享一下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'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>
在目錄下加入服務器配置文件.htaccess
RewriteEngine on ############################### # @email test@test.com # @author test ############################### #重寫規則 #如果是一個目錄或者文件,就訪問目錄或者文件 RewriteCond %{REQUEST_FILENAME} !-d #如果文件存在,就直接訪問文件,不進行下面的RewriteRule RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php
在框架配置項\frontend\config\main.php中加入urlManager配置項
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, //'suffix' => '.html',//URL后綴],
最后,重啟服務器。
看完了這篇文章,相信你對“yii框架路由配置的示例”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。