Typecho程式偽靜態規則大全(包括Linux/Windows)

來源:互聯網
上載者:User

雖然老左部落格是用的Wordpress程式,但是我不得不說wp程式即便是一款非常棒的程式之一,但是在資源佔用方面的問題還是比較差的。如果你使用過WP程式建立部落格應該知道,在網站訪問量達到幾百的時候一般的主機CPU會超標,甚至會出現被暫停主機使用。因為一般的主機產品CPU限制為5-10%,所以很容易超標。Typecho部落格程式是國人開發的,雖然目前不在更新但是功能基本完善,結構看類似WORDPRESS,但是在佔用資源上比WP好很多。所以Typecho使用者還是非常多的。

Typecho程式的偽靜態規則不同於wp直接預設可用,需要我們手工載入到空間中才可以生效。下面老左整理了這款程式在不同的主機環境中的偽靜態規則,希望對大家有所協助。

1、Linux Apache環境(.htaccess):
複製代碼 代碼如下:<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目錄,檔案夾要修改路徑,如 /laozuo/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

# 帶 www 的跳轉到不帶的
RewriteCond %{HTTP_HOST} ^www.laozuo.org
RewriteRule (.*) http://laozuo.org/$1 [R=301,L]

# 不帶 www 的跳轉到帶的
RewriteCond %{HTTP_HOST} ^laozuo.org
RewriteRule (.*) http://www.laozuo.org/$1 [R=301,L]
</IfModule>

2、Linux Apache環境(Nginx):
複製代碼 代碼如下:location / {
index index.html index.php;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
rewrite (.*) /index.php;
}
}

3、Windows IIS偽靜態(httpd.ini):
複製代碼 代碼如下:[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# 中文tag解決
RewriteRule /tag/(.*) /index\.php\?tag=$1
# sitemapxml
RewriteRule /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]
# feed
RewriteRule /feed/(.*) /index.php/feed/$1 [L]
# 日期歸檔
RewriteRule /2(.*) /index.php/2$1 [L]
# 上傳圖片等
RewriteRule /action(.*) /index.php/action$1 [L]

因為老左只有apache空間,所以測試是沒有問題的,其他環境有朋友可以測試,如果遇到問題可以給我留言。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.