queryphp架構教程三 做SEO最佳化 以.html結尾去除index.php解決思路

來源:互聯網
上載者:User
queryphp架構教程三 做SEO最佳化 以.html結尾去除index.php
前二篇教程
http://topic.csdn.net/u/20100228/22/3bea834b-efc0-4aa0-af4a-a4923af8b60c.html
http://topic.csdn.net/u/20100226/12/43bf3dc5-795f-4fa5-861a-2f7bf8fd0cd6.html
下載 目前最新0.9.6.8beta版
http://code.google.com/p/queryphp/downloads/list

去除index.php測試

C:\WINDOWS\system32\drivers\etc\hosts檔案添加一行
內容如下
127.0.0.1 localhost
192.168.0.10 www.app.com

192.168.0.10的是你自己apache使用的IP,就是下面
*號中的IP,反證能訪問你的本地網卡就可以了

http://www.app.com/queryphp/project/index.php/default/index
配置後希望可以變成這樣子
http://www.app.com/queryphp/project/default/index.html
記得在inc.ini.php檔案裡面加多一行
$config['html']='.html'; 或把前面那個//去掉,這樣就可以了
虛擬機器主機配置測試,AllowOverride FileInfo 將會使用.htaccess配置


Order allow,deny
Allow from all
AllowOverride FileInfo

DocumentRoot "D:/work"
ServerName "www.app.com"



.htaccess檔案 放在project目錄下面 就是每個項目目錄下面,這樣就會訪問同級目錄
index.php檔案

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.app.com/queryphp/project/curd/index

是不是可以顯示內容了


如果顯示了 在framework\config\inc.ini.php 檔案中把下面這行內容去掉注釋
//$config['html']='.html';//開啟.html結尾url


http://www.app.com/queryphp/project/curd/index.html 訪問
是不是可以看到內容了

所有連結都帶.html結尾了。那我們有時候想不要.html結尾怎麼辦
">刪除

url_for(url,true);方式 表示不要html結尾
刪除會變成這樣子
http://www.app.com/queryphp/project/curd/delete/id/2

------解決方案--------------------
wow 頂

------解決方案--------------------
試問LZ用過那幾種架構
------解決方案--------------------
探討
用過幾種,目前基本是山寨symfony+doctrine ORM類
自己也在使用,不過感覺太大了,自己寫一個小的。

------解決方案--------------------
反反覆複共發放給法國風格
------解決方案--------------------
做OA,或企業網站,初學者.用什麼架構好
------解決方案--------------------
支援~~~~~~~~~~~~~~~~~~~~~~學習。
------解決方案--------------------
學習了

------解決方案--------------------
urlrewrite老是不太明白
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.