歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> Typecho程序偽靜態規則大全(包括Linux/Windows)

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

日期:2017/3/2 16:31:45   编辑:Linux服務器
雖然老左博客是用的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空間,所以測試是沒有問題的,其他環境有朋友可以測試,如果遇到問題可以給我留言。
Copyright © Linux教程網 All Rights Reserved