其实刚接触Typecho时,为伪静态这件事也头疼过。.
Typecho程序的伪静态规则不同于wp直接默认可用,需要我们手工加载到空间中才可以生效。
后面在网站上搜索发现网上已经有现成写好的,这里就搬运一下吧,以后找起来也方便一些!
1、Linux Apache环境(.htaccess):
<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目录,文件夹要修改路径,如 /lvmoo/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# 带 www 的跳转到不带的
RewriteCond %{HTTP_HOST} ^www.lvmoo.com
RewriteRule (.*) http://lvmoo.com/$1 [R=301,L]
# 不带 www 的跳转到带的
RewriteCond %{HTTP_HOST} ^lvmoo.com
RewriteRule (.*) http://www.lvmoo.com/$1 [R=301,L]
</IfModule>
2、Linux 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和Nginx,IIS的暂时还未测试!
(搬运老左博客,本人略有加工)