Typecho 程式各種 Web 伺服器偽靜態規則大全

7,672 2

Typecho 是由國人開發的一套非常優秀的部落格系統,程式碼短小,簡單友善,最近也有個專案是用 Typecho 搭建的,理所當然地對該程式有了一點探討,最大的問題還是在偽靜態方面,官方沒有給出 IIS 和 Nginx 的偽靜態規則,還得我折騰老半天去搜尋資料,還要測試相容性,所幸忙了許久還是有收穫的,下面我就發上各種 Web 伺服器搭建 Typecho 的偽靜態規則,省得大家麻煩去找。

Apache

Plain Text
<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]</IfModule>

Nginx

Plain Text
if (!-e $request_filename) {    rewrite ^(.*)$ /index.php$1 last;}

IIS

Plain Text
[ISAPI_Rewrite]CacheClockRate 3600RepeatLimit 32RewriteRule /tag/(.*) /index\.php\?tag=$1RewriteRule /sitemap.xml /sitemap.xml [L]RewriteRule /favicon.ico /favicon.ico [L]RewriteRule /(.*).html /index.php/$1.html [L]RewriteRule /(.*)/comment /index.php/$1/comment [L]RewriteRule /category/(.*) /index.php/category/$1 [L]RewriteRule /page/(.*) /index.php/page/$1 [L]RewriteRule /search/(.*) /index.php/search/$1 [L]RewriteRule /feed/(.*) /index.php/feed/$1 [L]RewriteRule /2(.*) /index.php/2$1 [L]RewriteRule /action(.*) /index.php/action$1 [L]

規則是根據正式版 1.1 寫的,如果有什麼問題可以在下方留言提出。

評論

(2)
  1. Chrome 81 Windows 10

    谢谢你的帮助,现在我也设置好了伪静态,可以改网址了

發佈評論