Yii系列總結:隱藏index.php步驟
1.開啟apache的mod_rewrite模組
?????去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符號
?????確保中有“AllowOverride All”
2.在項目中的/protected/config/main.php中添加代碼:
-----------------------------------------
'components'=>array(
???????????...
???????????'urlManager'=>array(
?????????????????'urlFormat'=>'path',
?????????????????'showScriptName'=>false,//注意false不要用引號括上
???????????'urlSuffix'=>'.html',
?????????????????'rules'=>array(
?????????????????????'sites'=>'site/index',
?????????????????),
???????????),
???????????...
???????),
------------------------------------------
3.在與index.php檔案同級目錄下添加檔案“.htaccess”,內容如下: ??
----------------------------
Options +FollowSymLinks
???IndexIgnore */*
???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