How to: Yii Hide index.php files
Author: zccst
1. Modify the Apache configuration httpd.conf
(1) Open Apache Mod_rewrite module to remove the "#" symbol before LoadModule rewrite_module modules/mod_rewrite.so
(2) ensure There are "allowoverride all" in the
Annotations: For Wamp, the second allowoverride all is turned on.
allowoverride in Apache configuration file three times, but only one place needs all, the other two places are none.
(3) Restart Apache
2. Add the code in the/protected/config/main.php in the project:
' Components ' =>array (... ') Urlmanager ' =>array ( ' urlformat ' = ' path ', ' showscriptname ' =>false,//note false do not enclose in quotation marks ' Urlsuffix ' + '. html ',//ride plus. html suffix, overbearing ' rules ' =>array ( ' sites ' = ' site/index ', ) , ... ),
3. Under the same sibling directory as the index.php file AddFile ". htaccess", which reads as follows:
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
Annotations: This section is also available in Yii's official guide:
See: Http://www.yiiframework.com/doc/guide/1.1/zh_cn/topics.url
This makes it possible to hide the index.php entry file.