首先要在服務(wù)器配置(httpd.conf)中開(kāi)啟重寫(xiě)模塊
#開(kāi)啟重寫(xiě)模塊,將其前面的#去掉 LoadModule?rewrite_module?modules/mod_rewrite.so #Directory中允許覆蓋開(kāi)啟 <directory> ????# ????#?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>
在目錄下加入服務(wù)器配置文件.htaccess
RewriteEngine?on ############################### #?@email?test@test.com #?@author?test ############################### #重寫(xiě)規(guī)則 #如果是一個(gè)目錄或者文件,就訪問(wèn)目錄或者文件 RewriteCond?%{REQUEST_FILENAME}?!-d #如果文件存在,就直接訪問(wèn)文件,不進(jìn)行下面的RewriteRule RewriteCond?%{REQUEST_FILENAME}?!-f RewriteRule?.?index.php
在框架配置項(xiàng)frontendconfigmain.php中加入urlManager配置項(xiàng)
'urlManager'?=>?[???? 'enablePrettyUrl'?=>?true, ????'showScriptName'?=>?false,???? ????//'suffix'?=>?'.html',//URL后綴],
最后,重啟服務(wù)器。
相關(guān)文章教程推薦:yii教程
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END