p h p 配 置 僞 靜 態

1.檢測Apache是否支持mod_rewrite 

通過php提供的phpinfo()函數查看環境配置,通過Ctrl+F查找到“Loaded Modules”,其中列出了所有apache2handler已經開啓的模塊,如果裏面包括“mod_rewrite”,則已經支持,不再需要繼續設置。 

如果沒有開啓“mod_rewrite”,則打開目錄 您的apache安裝目錄“/apache/conf/” 下的 httpd.conf 文件,通過Ctrl+F查找到“LoadModule rewrite_module”,將前面的”#”號刪除即可。 

2.讓apache服務器支持.htaccess 

如何讓自己的本地APACHE服務器支持”.htaccess”呢?其實只要簡單修改一下apache的httpd.conf設置就可以讓 APACHE支 持.htaccess了。打開httpd.conf文件(在那裏? APACHE目錄的CONF目錄裏面),用文本編輯器打開後,查找 

Options FollowSymLinks AllowOverride None 改爲 

Options FollowSymLinks AllowOverride All 就可以了。 

.3.建立.htaccess 文件 

如果是在windows平臺下,剛開始還真不知道怎麼建立”.htaccess”文件,因爲這個文件實際上沒有文件名,僅僅只有擴展名,通過普通方式是無法建立這個文件的,彆着急,馬上告訴你三種方法:三種方法都是先建立一個htaccess.txt的文本文件(當然,這個文本文件的名字你可以隨便取),然後有三種方式給這個文件重命名: 



     全國註冊建築師、建造師考試  備考資料  歷年真題  考試心得  模擬試題      

 



(1)用記事本 打開,點擊文件–另存爲,在文件名窗口輸入”.htaccess”,注意是整個綠色部分,也就是包含英文引號,然後點擊保存就行了。 

(2)進入cmd命令 窗口,通過cd切換當剛建立htaccess.txt文件的文件夾,然後輸入命令:rename htaccess.txt .htaccess ,然後點擊鍵盤Enter鍵即可。 4.簡單.htaccess的寫法,實例。   

RewriteEngine on RewriteBase / 

RewriteRule ^index.html$ 

 

 

  index.php  

RewriteRule ^tz_goods_list.html$  

 

 

tz_goods_list.php 

RewriteRule ^tz_goods_type_det_([0-9]+)\.html$   tz_goods_type_det.php?type_id=$1 RewriteRule ^tz_goods_det_([0-9]+)\.html$   tz_goods_det.php?goods_id=$1  

RewriteRule ^tz_download_list.html$    tz_download_list.php RewriteRule ^tz_download_det_([0-9]+)\.html$   tz_download_det.php?id=$1  

RewriteRule ^tz_news_list.html$  

 

 

 tz_news_list.php 

RewriteRule ^tz_news_lists_([0-9]+)\.html$   tz_news_lists.php?type_id=$1 RewriteRule ^tz_news_det_([0-9]+)\.html$   tz_news_det.php?id=$1  

RewriteRule ^tz_case_list.html$     tz_case_list.php RewriteRule ^tz_case_det_([0-9]+)\.html$   

tz_case_det.php?id=$1 

 

RewriteRule ^tz_hezuo_list.html$    tz_hezuo_list.php RewriteRule ^tz_hezuo_lists_([0-9]+)\.html$   tz_hezuo_lists.php?type_id=$1 RewriteRule ^tz_hezuo_det_([0-9]+)\.html$   tz_hezuo_det.php?id=$1  

RewriteRule ^tz_support_list.html$ 

 

 

 tz_support_list.php RewriteRule ^tz_support_lists_([0-9]+)\.html$   tz_support_lists.php?type_id=$1 RewriteRule ^tz_support_det_([0-9]+)\.html$   

tz_support_det.php?id=$1 

 

RewriteRule ^tz_tianzhu_team.html$    tz_tianzhu_team.php RewriteRule ^tz_tianzhu_service.html$    tz_tianzhu_service.php RewriteRule ^tz_tianzhu_recruit.html$    tz_tianzhu_recruit.php RewriteRule ^tz_tianzhu_payment.html$    tz_tianzhu_payment.php RewriteRule ^tz_tianzhu_friend.html$    tz_tianzhu_friend.php RewriteRule ^tz_tianzhu_culture.html$    tz_tianzhu_culture.php RewriteRule ^tz_tianzhu_contact.html$    tz_tianzhu_contact.php RewriteRule ^tz_tianzhu_company.html$ 

 

 

 tz_tianzhu_company.php 




 



 

5.靜態頁面裏的鏈接如何寫 

<a href="reply.php?id=^$arr.id^">     ========    <a href="reply_^$arr.id^.html">


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章