PHP架構queryphp教程:入門九 如何去掉index.php
去除index.php測試
C:\WINDOWS\system32\drivers\etc\hosts檔案添加一行
內容如下
127.0.0.1 localhost
192.168.0.10 www.tjwzjs.cn
192.168.0.10的是你自己apache使用的IP,就是下面
*號中的IP,反證能訪問你的本地網卡就可以了
http://www.tjwzjs.cn/queryphp/project/index.php/default/index
配置後希望可以變成這樣子
http://www.tjwzjs.cn/queryphp/project/default/index.html
記得在inc.ini.php檔案裡面加多一行
$config['html']='.html'; 或把前面那個//去掉,這樣就可以了
虛擬機器主機配置測試,AllowOverride FileInfo 將會使用.htaccess配置
虛擬機器主機配置測試檔案在apache虛擬機器主機裡面:
Order allow,deny
Allow from all
AllowOverride FileInfo?
?
DocumentRoot "D:/work"
ServerName "www.app.com"
.htaccess檔案 放在project目錄下面 就是每個項目目錄下面,這樣就會訪問同級目錄
index.php檔案
index.php 目錄下.htaccess檔案:
RewriteEngine On
?
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
?
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
?
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
?
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
------------------------
程式中使用url_for()方式
模板中示樣本 我們還是以CURD方式?
">編輯
">刪除
下載後在並在apache設定www.app.com 在c:/windows/system
http://www.tjwzjs.cn/queryphp/project/curd/index
是不是可以顯示內容了
如果顯示了 在framework\config\inc.ini.php 檔案中把下面這行內容去掉注釋
//$config['html']='.html';//開啟.html結尾url
http://www.tjwzjs.cn/queryphp/project/curd/index.html 訪問
是不是可以看到內容了
所有連結都帶.html結尾了。那我們有時候想不要.html結尾怎麼辦
">刪除
url_for(url,true);方式 表示不要html結尾
刪除會變成這樣子
http://www.tjwzjs.cn/queryphp/project/curd/delete/id/2?
原文來源:http://tjwzjs.cn/news/knowledge/2012/1210/56.html