萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網路程式設計 >> PHP 程式設計

淺析偽靜態在 phpWind 中的應用與 Apache/IIS 設定

偽靜態能將動態 URL 轉為靜態化外觀,利於 SEO 並提升用戶信任度。本文說明 phpWind 在虛擬主機與獨立伺服器上的偽靜態規則設定。

虛擬主機(Apache + .htaccess)

確認空間支援 mod_rewrite 並允許 .htaccess 覆寫。將下列內容存為 .htaccess 放入網站根目錄:

RewriteEngine On
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)simple/([t|f].+).html$ /simple/index.php?$2.html

獨立伺服器:Windows 2003 + IIS + ISAPI_Rewrite

  1. 安裝 ISAPI_Rewrite 元件。
  2. 編輯 httpd.ini:
[ISAPI_Rewrite]
# 防蠕蟲攻擊
RewriteRule .*(?:global\.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# phpWind 規則
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/simple/([a-z0-9_]+\.html)$ $1/simple/index.php?$2

舊版 phpWind 注意

若為舊版,將第一條規則改為:

RewriteRule ^(.*)-htm-(.*)$ $1/.php?/$2

驗證方式

瀏覽器訪問 https://domain/forum-htm-fid-1.html 等偽靜態網址,若正常顯示內容即設定成功。

copyright © 萬盛學電腦網 all rights reserved