PHP架構queryphp教程:入門九 怎麼去掉index.php

來源:互聯網
上載者:User
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

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.