Typecho伪静态规则及301跳转设置

作者: 时间:
浏览 : 716

一、Typecho在Apache环境下的伪静态规则(.htaccess文件或httpd.conf配置)

<IfModule mod_rewrite.c>
RewriteEngine On
# 下面是在根目录,文件夹要修改路径,如 /typecho/,同时 RewriteRule 也要跟着变
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

 

带www域名跳转到不带www的域名

RewriteCond %{HTTP_HOST} ^www.zhangwenbao.com
RewriteRule (.*) http://zhangwenbao.com/$1 [R=301,L]

 

不带www域名跳转到带www的域名

RewriteCond %{HTTP_HOST} ^zhangwenbao.com
RewriteRule (.*) http://www.zhangwenbao.com/$1 [R=301,L]

 

注:最新的 SVN 在后台启用重写功能的时候能自动生成 .htaccess 文件。

二、Typecho在Nginx环境下的伪静态规则(conf文件配置)

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;
}
}

 

三、Typecho在SAE环境下的伪静态规则(config.yaml文件配置)

name: typecho
version: 1
#cron:
# - description: cron test
# url: index.php
# schedule: every 43 mins
# timezone: Beijing
handle:
- rewrite: if(!is_dir() && !is_file()) goto "index.php?%{QUERY_STRING}"

 

四、Typecho在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]

 

另一个:

[ISAPI_Rewrite]
# 重定向后台地址
RewriteRule ^/admin(.*) /admin/$1 [L]
# 将带html htm 后缀的重写
RewriteRule ^(.*)(html|htm)$ /index\.php/$1$2 [L]
# 排除带"."的 其余的全部重写
RewriteRule ^([^.]+)$ /index\.php/$1 [L]

 

注意:配置好伪静态后,记得到Typecho后台设置永久链接里,启用地址重写功能。

Tag标签:

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注