首先要在服務器配置(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>
(推薦教程:yii框架)
在目錄下加入服務器配置文件.htaccess
RewriteEngine on ############################### # @email test@test.com # @author test ############################### #重寫規(guī)則 #如果是一個目錄或者文件,就訪問目錄或者文件 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后綴],
更多編程相關內(nèi)容,請關注php中文網(wǎng)編程教程欄目!
以上就是yii框架如何配置路由的詳細內(nèi)容,更多請關注php中文網(wǎng)其它相關文章!
路由優(yōu)化大師是一款及簡單的路由器設置管理軟件,其主要功能是一鍵設置優(yōu)化路由、屏廣告、防蹭網(wǎng)、路由器全面檢測及高級設置等,有需要的小伙伴快來保存下載體驗吧!
Copyright 2014-2025 http://www.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號