1. Open Apache Mod_rewrite module
#去掉LoadModule Rewrite_module modules/mod_rewrite.so before the "#" symbol # if it is an Ubuntu system, the default is to turn on rewrite cd/etc/apache2/ mods-enabled# See if there is a rewrite.load link file, and if not, establish a linked file Cd/etc/apache2/mods-enabledln-s: /mods-available/rewrite.load rewrite.load//This step is not verified
2, ensure <directory "..." ></Directory> "allowoverride All"
Here's an example, other things like:
#现有一个工程project, you need to configure the virtual host document cd /etc/apache2/sites-availablesudo vi project# to put the following contents <virtualhost *:80> ServerAdmin [email protected] ServerName baike.petshome.cn documentroot /var/www/project <directory /> Options followsymlinks allowoverride all </directory> <Directory /var/www/project> Options FollowSymLinks MultiViews allowoverride all Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # possible values include: debug, info, notice, warn, error, crit, # alert, emerg. loglevel warn customlog ${apache_ Log_dir}/access.log combined</virtualhost> #然后确保AllowOverride all can be
3. Modify the project configuration file to modify the code in the/protected/config/main.php in the project
‘components‘=>array(
...
‘urlManager‘=>array(
‘urlFormat‘=>‘path‘,
‘showScriptName‘=>false,//注意false不要用引号括上
...
),
4. Add the file ". htaccess" in the same directory as the index.php file.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
rewritecond Span style= "Color:rgb (147,161,161); class=" pun ">%{ request _filename } !-
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
This will hide the index.php entry file.
Reference: http://www.yiiframework.com/forum/index.php/topic/1061-%e9%9a%90%e8%97%8findexphp%e7%9a%84%e6%ad%a5%e9%aa%a4/
This article is from the "Lost Moon" blog, please be sure to keep this source http://luecsc.blog.51cto.com/2219432/1436656