導航:首頁 > 編程語言 > php路徑轉換

php路徑轉換

發布時間:2025-07-13 20:54:40

⑴ 求助php偽靜態,如何將動態PHP頁面改為偽靜態頁面

偽靜態實際上就是把 index.php?act=about&cid=1 將這種形式的動態路徑用 about-1.html 這種形式輸出,也就是說瀏覽器每次訪問about-1.html地址能打開相應的index.php?act=about&cid=1動態網址。

偽靜態的實現本質上是配置伺服器進行路徑轉換,根據不同的伺服器環境,配置方法也不太一樣,PHP+iis6的話就要配置httpd.ini文件,php+iis7就要配置web.config,PHP+apache就要配置.htaccess文件(或者httpd.conf)

.htaccess(或者httpd.conf)文件的規則示例:
RewriteEngine on
RewriteRule ^/?(index|guestbook|online)\.html$ index\.php [L]
RewriteRule ^/?(eindex)\.html$ index\.php?act=$1 [L]
RewriteRule ^/?(index|guestbook|online)-([0-9]+).html$ index\.php\?p=$2 [L]
RewriteRule ^/?([a-z0-9]+)_([0-9]+).html$ index\.php\?act=$1&id=$2 [L]
RewriteRule ^/?([a-z0-9]+)-([0-9]+).html$ index\.php\?act=$1&cid=$2 [L]
RewriteRule ^/?([a-z0-9]+)-([0-9]+)-([0-9]+).html$ index\.php\?act=$1&cid=$2&p=$3 [L]

httpd.ini示例:
[ISAPI_Rewrite]
RepeatLimit 32
# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [F,I,O]
# Block external access to the Helper ISAPI Extension
RewriteRule .*\.isrwhlp / [F,I,O]
RewriteRule ^/(index|guestbook|online)\.html$ /$1\.php
RewriteRule ^/(eindex).html$ /index\.php\?act=$1
RewriteRule ^/(index|guestbook|online)-([0-9]+).html$ /$1\.php\?p=$2
RewriteRule ^/([a-z0-9]+)_([0-9]+).html$ /index\.php\?act=$1&id=$2
RewriteRule ^/([a-z0-9]+)-([0-9]+).html$ /index\.php\?act=$1&cid=$2
RewriteRule ^/([a-z0-9]+)-([0-9]+)-([0-9]+).html$ /index\.php\?act=$1&cid=$2&p=$3

⑵ php語言url路徑中英文轉換問題

加密 urlencode加密和urldecode解密處理

閱讀全文

與php路徑轉換相關的資料

熱點內容
補碼位數進1怎麼變回源碼 瀏覽:287
linux如何安裝中文 瀏覽:404
怎麼中斷伺服器或共享的所有連接 瀏覽:152
最美c語言編譯器 瀏覽:1000
安卓手機如何錄像的時候放音樂 瀏覽:199
二手r720伺服器怎麼樣 瀏覽:172
程序員那麼可愛化妝是哪一集 瀏覽:481
還是一個程序員好 瀏覽:733
shell運行python程序 瀏覽:321
墨跡小視頻緩存在哪個文件夾 瀏覽:248
我的世界喪屍大逃殺是什麼伺服器 瀏覽:404
博客虛擬資源網站源碼 瀏覽:138
王羲之聖教序pdf 瀏覽:566
程序員要多久才能年薪50萬 瀏覽:256
浪潮伺服器怎麼開機箱 瀏覽:92
我的世界伺服器ice怎麼設置密碼 瀏覽:373
我的世界伺服器怎麼設置成op 瀏覽:228
伺服器上的圖片如何最小 瀏覽:247
python爬蟲高級視頻教程 瀏覽:800
如何把微信的錢轉到支付寶的app 瀏覽:953