Emlog博客用.heaccess自定义、绑定子目录、重定向
[点点滴滴]
下面是我的博客的.heaccess的内容,多是多了点,可能大家有用的到的哦!比如:有的虚拟主机不提供绑定子目录(这也是主机上为着服务器的安全哈),然后站长们需要绑定自己的wap域名,下面这些东西就能实现
<IfModule mod_rewrite.c>
#404:服务器找不到指定的资源,请求的网页不存在(譬如浏览器请求的网页被删除或者移位,但不排除日后该链接有效的可能性);
#410:请求的网页不存在(注意:410表示永久性,而404表示临时性);
#200:服务器成功返回请求的网页;
#301:网址永久性重定向
#302:网址临时性重定向
# =====域名伪静态转发====
RewriteCond %{HTTP:Host} ^my\.csfep\.cn$
RewriteRule (.*) http\://www\.xxshui\.com\.cn/$1 [NC,R=302]
# =====域名伪静态转发====
RewriteCond %{HTTP:Host} ^xxshui\.com\.cn$
RewriteRule (.*) http\://www\.xxshui\.com\.cn/$1 [NC,R=301]
# =====域名伪静态转发====
#RewriteCond %{HTTP:Host} ^m\.xxshui\.com\.cn$
#RewriteRule (.*) http\://www\.xxshui\.com\.cn/wap/$1 [NC,R=302]
#==绑定wap子目录 开始== 把 xxshui.com.cn 改为你要绑定的域名.
RewriteCond %{HTTP_HOST} ^m.xxshui.com.cn$
#RewriteCond %{HTTP_HOST} ^(m.)?xxshui.com.cn$
# 把 wap 改为要绑定的目录.
RewriteCond %{REQUEST_URI} !^/wap/
# 不要改以下两行.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 把 wap 改为要绑定的目录.
RewriteRule ^(.*)$ /wap/$1
# 把 xxshui.com.cn 改为你要绑定的域名
# 把 wap改为要绑定的目录.
# wap/ 后面是首页文件index.php, index.html
RewriteCond %{HTTP_HOST} ^m.xxshui.com.cn$
#RewriteCond %{HTTP_HOST} ^(m.)?xxshui.com.cn$
RewriteRule ^(/)?$ wap/index.php [L]
#==绑定wap子目录 结束==
# =====域名伪静态转发====
RewriteCond %{HTTP:Host} ^m\.csfep\.cn$
RewriteRule (.*) http\://www\.xxshui\.com\.cn/wap/$1 [NC,R=302]
# ====404===
ErrorDocument 404 /notfound.php
RewriteEngine on
RewriteBase /
RewriteRule ^(post|record|sort|author|page)-([0-9]+)\.html$ index.php?$1=$2
RewriteRule ^tag-(.+)\.html$ index.php?tag=$1
</IfModule>
说明:上面的代码,可以实现:http://www.xxshui.com.cn/wap/和http://m.xxshui.com.cn/wap/和http://m.xxshui.com.cn/访问的是同一结果,但是对于应用到BBS的网站,可以提高相应的网页收录率


