2012年12月

typecho 博客适用,其他未知。

一、Apache


RewriteEngine On
#你的博客目录,可能是/或/blog,用它替换Your_blog_dir,下同
RewriteBase Your_blog_dir
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ Your_blog_dir/index.php/$1 [L]

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

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

二、Nginx

location / {  #1
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;  #10
}
}

这个有必要说两句,百度搜到的,几乎全是上面所写,那我的博客目录是/blog的话,就不适用了。怎么办?看着:
把上面#1、#10行改为

根据你的博客路径修改

location /blog {
rewrite (.*) /blog/index.php;

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

if ($host ~* (blog.|^)(0x84.com)) {
set $without_www $2;
rewrite (.*) http://www.$without_www$1 permanent;
}

三、Lighttpd

文章 | 标签 | 分页 | RSS | 分类 | 归档 | 搜索 | 独立页面

url.rewrite = (
"^/(archives|tag|page|feed|category|[0-9]{4}|search|guestBook.html)(|/.*)" => "/index.php/$1$2",
)

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

$HTTP["host"] !~ "^(www\.0x84\.com)$" {
url.redirect = ( "^/(.*)" => "%1/$1" )
}

注:请记得到后台永久链接设置里,启用地址重写功能。

1、最简单的

<head>
<meta http-equiv="refresh" content="2;url=/blog/index.php">
</head>

2、PHP

<?php
Header("HTTP/1.1 301 Moved Permanently");
Header("Location:/blog/index.php");
?>

3、.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.dumiqiu.cn$ [NC]
RewriteRule ^(.*)$ http://www.dumiqiu.cn/$1 [L,R=301]