例如你的原路徑是 http://localhost/test/index.php/index/add
那麼現在的地址是 http://localhost/test/index/add
如何去掉index.php呢?
1.httpd.conf設定檔中載入了mod_rewrite.so模組 //在APACHE裡面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警號去掉
2.AllowOverride None 講None改為 All //在APACHE裡面去配置
<Directory "D:/server/apache/cgi-bin">AllowOverride none 改 AllowOverride ALLOptions NoneOrder allow,denyAllow from all</Directory>
3.確保URL_MODEL設定為2,
在項目的設定檔裡寫
return Array('URL_MODEL' => '2',);
4 .htaccess檔案必須放到跟目錄下
這個檔案裡面加:
<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>
補充:在windows下不能建立以點開頭的檔案,你可以先隨便建立一個檔案
然後在DOS在操作 rename xxxx.xxxx .htaccess
或者開啟記事本寫入htaccess然後另存新檔.htaccess即可
如果出現403錯誤則將.htaccess開啟在開頭添加Options +FollowSymLinks
即:
Options +FollowSymLinks<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>
即可解決.
無許可權也是加上Options +FollowSymLinks
相關推薦:
ThinkPHP中關聯查詢執行個體,ThinkPHP關聯執行個體