對於學建站新手,推薦剛開始使用 WordPress 程式學習做網站,由於 WordPress 是 PHP 程式,它與 LINUX 空間配合很好,但仍有很多做網站新手會購買到 windows 屬性空間,就導致了安裝 WordPress 程式之後,偽靜態出現連結中含有 index.php 的情況。

那麼如何去除連結中的 index.php 呢?有二個方法,一個是使用外掛,另一種是使用純程式碼修改。下面講講如何使用無外掛純程式碼方式去除網站連結中的 index.php 。

首先桌面新建一個 txt 文字,然後複製以下程式碼至 txt 檔案中:

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based WordPress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal WordPress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

然後儲存文字檔案為 httpd.ini 檔案;再將 httpd.ini 檔案上傳至自己做網站的空間根目錄。再次重新整理網站首頁,就會看到連結中的 index.php 被去除了。