yii1.0隱藏index.php的方法:先開啟「httpd.conf」檔案;然後開啟「mod_rewrite.so」;接著將相對應目錄的「AllowOverride」改為ALL;最後在index. php同級目錄下新建.htaccess。
本文操作環境:windows7系統、yii1.0版,DELL G3電腦
YII 1.0 隱藏單入口index.php 設定路由與偽靜態
隱藏index.php
保證apache設定檔httpd.conf裡的LoadModule
rewrite_module modules/mod_rewrite.so開啟(去掉#)
將對應目錄的AllowOverride 改為ALL
在根目錄下,即在index.php同級目錄下新建.htaccess
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
設定main.php 中的路由規則
// uncomment the following to enable URLs in path-format 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName' =>false, 'rules'=>array( 'index.html'=>array('index'), 'article/<id:\d+>' => array('article/index','urlSuffix'=>'.html'), 'category/<id:\d+>/<page:\d+>' => array('category/index','urlSuffix'=>'.html'), 'category/<id:\d+>/1' => array('category/index','urlSuffix'=>'.html'), ), ),
推薦:《yii教學》
以上是yii 1.0 index.php怎麼隱藏的詳細內容。更多資訊請關注PHP中文網其他相關文章!