一、首先打開apache的配置文件,httpd.conf,找到#LoadModule rewrite_module modules/mod_rewrite.so,去掉前面的#號,開啓mod_rewrite模塊 php
二、找到 html
<Directory /> Options FollowSymLinks AllowOverride none Order deny,allow Deny from all </Directory>
修改成:
<Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all </Directory>
三、找到
<Directory "D:/Program Files (x86)/Web/www">
# Possible values for the Options directive are "None", "All",
# or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride none # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory>
修改成:
<Directory "D:/Program Files (x86)/Web/www"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory>
以上主要是修改 AllowOverride one爲 AllowOverride All
四、打開你的ci目錄的application/config下的config.php,查找$config['index_page']變量,將它的值留空
五、爲ci編寫.htaccess文件,站長的CI安裝在網站根目錄的friend目錄下,應此.htaccess的內容以下:
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /friend/index.php/$1 [QSA,PT,L] </IfModule>
若是你的ci就是安裝在網站根目錄,那麼,你的.htaccess內容應該爲:
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /index.php/$1 [QSA,PT,L] </IfModule>
嗯,相信你們都看出區別了,就是多了一個ci的安裝目錄,可是卻很重要。
六、重啓apache,搞定。