Steps for hiding the index. php file in Yii

Source: Internet
Author: User
Yii hides the index. php file step by zccst1. modify Apache configuration httpd. conf & nbsp; (1) enable the mod_rewrite module of apache to remove the "#" symbol before LoadModulerewrite_modulemodulesmod_rewrite.so & nbsp; & nbsp Yii hide index. php file steps
Author: zccst

1. modify httpd. conf in Apache configuration
(1) enable the mod_rewrite module of apache to remove the "#" symbol before LoadModule rewrite_module modules/mod_rewrite.so.
(2) ensure "AllowOverride All"
Annotation: for wamp, the second AllowOverride All is enabled.
AllowOverride appears three times in the Apache configuration file, but only one place requires All, and the other two places are None.
(3) restart Apache

2. add the code to/protected/config/main. php in the project:
'Components' => array (... 'urlmanager' => array ('urlformat' => 'path', 'showscriptname' => false, // be sure not to enclose 'urlsuffix '=> '.html' in quotation marks for 'false ', // add the suffix ".html" to the train, and overlay the 'rules' => array ('sites '=> 'site/Index ',),),...),


3. add the file ". htaccess" in the same directory as the index. php file. the content is 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

Note: This section is also available in the yii Official Guide:
See: http://www.yiiframework.com/doc/guide/1.1/zh_cn/topics.url

In this way, you can hide the index. php entry file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.