至从网站升级后,由于采用了自定义链接名称和目录式访问,以前网站做的伪静态页,全是.html为扩展名的静态页,现在百度和Google收录的网址都是以前的伪静态页,网站升级后,访问量突然少了很多很多,原来是网址不能达到正常的页面,难怪最近一段时间GG全是鸡蛋,我一直在研究如何写.htaccess访问规则,一直没成功,很是郁闷啊。今天上午睡觉起来,看到QQ群里油菜正在抱怨,也是网址不能到达的原因,哈哈。我看到这个消息突然灵感来了,我说看一下以前Sablog1.6的.htaccess文件,看一下以前的转发规则是怎么写的,我拿来改一下不就可以了么,于是说动就动,去论坛找了一下.htaccess规则内容,拿来改了改,中途还是没成功,但是让我看到希望,再改,最后终于搞定了。兼容了以前搜索引擎收录的网址。哈哈哈。。

下面来分享一下:
# BEGIN Sablog-X
<IfModule mod_rewrite.c>
RewriteEngine On

#升级前1.6的伪静态网址
RewriteRule ^show-([0-9]+)-([0-9]+)\.html$ index.php?action=show&id=$1&page=$2

#防盗链
RewriteCond %{HTTP_REFERER} !^https://samool.com/.*$ [NC]   
RewriteCond %{HTTP_REFERER} !^https://samool.com$ [NC]   
RewriteCond %{HTTP_REFERER} !^http://samool.com/.*$ [NC]   
RewriteCond %{HTTP_REFERER} !^http://samool.com$ [NC] 
RewriteRule .*\.(jpg|mp3|rm|wma|exe|rar|zip)$ https://samool.com/images/error.gif [R,NC]

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=13]

# 只带月份的归档
RewriteRule ^date/([0-9]{6})/?([0-9]+)?/?$ index.php?action=article&setdate=$1&page=$2 [QSA,L]

# 无分类翻页
RewriteRule ^page/([0-9]+)?/?$ index.php?action=article&page=$1 [QSA,L]

# 分类
RewriteRule ^category/([0-9]+)/?([0-9]+)?/?$ index.php?action=article&cid=$1&page=$2 [QSA,L]
RewriteRule ^category/([^/]+)/?([0-9]+)?/?$ index.php?action=article&curl=$1&page=$2 [QSA,L]

# 归档、高级搜索
RewriteRule ^(archives|search|article|links|about)/?$ index.php?action=$1 [QSA,L]


# 用户注册、登陆
RewriteRule ^(register|login)/?$ cp.php?action=$1 [QSA,L]

# 全部评论、标签列表、引用列表 带分页
RewriteRule ^(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ index.php?action=$1&page=$2 [QSA,L]

# tags
RewriteRule ^tag/([^/]+)/?([0-9]+)?/?$ index.php?action=article&item=$1&page=$2 [QSA,L]

# 文章
RewriteRule ^archives/([0-9]+)/?([0-9]+)?/?$ index.php?action=show&id=$1&page=$2 [QSA,L]

# 用户
RewriteRule ^uid/([0-9]+)/?([0-9]+)?/?$ index.php?action=article&uid=$1&page=$2 [QSA,L]
RewriteRule ^user/([^/]+)/?([0-9]+)?/?$ index.php?action=article&user=$1&page=$2 [QSA,L]

# 地图文件
RewriteRule sitemap.xml sitemap.php [QSA,L]

# 自定义链接
RewriteRule ^([^/]+)/?([0-9]+)?/?$ index.php?action=show&alias=$1&page=$2 [QSA,L]


</IfModule>
# END Sablog-X

Last modification:August 16, 2009
稀罕你