终于解决了困扰我很久的问题

samool 发布3 条评论17778 阅读

AI摘要

网站升级后,由于自定义链接名称和目录式访问,导致搜索引擎收录的网址无法访问,访问量减少。作者通过研究.htaccess访问规则,最终解决了问题,并分享了兼容以前搜索引擎收录网址的.htaccess规则内容。

至从网站升级后,由于采用了自定义链接名称和目录式访问,以前网站做的伪静态页,全是.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

  1. 01phpGrace nginx伪静态配置2019-11-22
  2. 02Bluefeel For Typecho2009-08-16
  3. 03Sablog探秘之《全面了解Sablog-X V2.0》2009-07-28
  4. 04cnbeta山寨版博客完成!!2009-06-07
  5. 05同花顺风格下载 For Sablog2.02008-08-12
  6. 06换个新主题,换种心情2008-08-04
  7. 07BackLinks的安装方法 For Sablog2.02008-07-21
  8. 08[成功解决]Sablog2.0后台发表文章不自动保存的bug2008-07-02
  9. 09纪念ChatGPT发布四周年!2026-11-25
  10. 10人生的下半场:向内安顿,向外生长2026-11-17
COMMENTS / 一纸留言

读者留言 3 条

一纸留言,便是山水间的一次相逢。

  1. cc cc

    求大人赏一个sa2.0用吧。。。
    [email protected]

    1. [quote=cc]求大人赏一个sa2.0用吧。。。
      [email protected][/quote]sablog 2.0还是在持续修改中.问题也有一些没解决掉.所以希望没有技术底子的还是暂时不要用.免得出问题.

  2. 我崇拜你啊,猫!

WRITE A COMMENT

写下你的留言