帝国CMS网站改版301规则怎么写.htaccess 301重定向URL重写
时间:2024年03月29日
/来源:网络
/编辑:佚名
窍门网站前段时间上线了“美容健身”频道,其中新建了很多子栏目,但是新建健身栏目的时候没有注意,没有修改文章内容页的保存目录,后来才发现,
直到今天准备修改一下目录,与窍门网站全站的文章内页目录保持一致,其中会用到.htaccess301重定向和百度站长工具的网站改版规划,
本篇主要介绍内容页的.htaccess301重定向跳转,百度的改版规则将在另外一篇文章中介绍。
.htaccess中的[NC][R][F][L]几个标记是什么意思
NC: no case,就是说不区分大小写
R:redirect,重定向
F:forbidden,禁止访问
L:last,表示已经是最后一条规则,.htaccess文件解析即将退出
原:健身子栏目文章地址为 /beauty/ydjs/office/20130408/20366.html
跳转到 /a/201304/20366.html
在.htaccess文件中添加如下内容
RewriteEngine On
RewriteRule ^beauty/ydjs/office/(\d{6})(\d{2})/(.*)$ /a/$1/$3 [NC,R=301]
NC,R 这几个参数现在就很容易理解了,NC:忽略大小写;R:跳转形式为301
可能有的朋友对上面的规则是怎么来的,不是太理解,其实.htaccess的规则是正则形式的,所以如果说你想了解更多规则的写法,可以先看下正则表达式方面的教程。
<IfModule mod_rewrite.c>
RewriteEngine On
ErrorDocument 404 /404.html
Rewritebase /
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^info/([0-9]+)-([0-9]+)(.*)$ /info/link/$1$3 [NC,R=301]
RewriteRule ^info/link/([0-9]+)\.php$ /info/link/$1\.html [NC,R=301]
RewriteRule ^info/sys/$ /list/72-0.html [NC,R=301]
RewriteRule ^info/sys/src/$ /list/75-0.html [NC,R=301]
RewriteRule ^info/sys/ziyuan/$ /list/73-0.html [NC,R=301]
RewriteRule ^info/sys/docc/$ /list/71-0.html [NC,R=301]
RewriteRule ^info/sys/shop/$ /list/78-0.html [NC,R=301]
RewriteRule ^info/rule/party/$ /list/21-0.html [NC,R=301]
RewriteRule ^info/report/deed/$ /list/32-0.html [NC,R=301]
RewriteRule ^info/lead/comment/$ /list/34-0.html [NC,R=301]
RewriteRule ^info/field/cliques/$ /list/62-0.html [NC,R=301]
RewriteRule ^info/model/zhan/$ /list/74-0.html [NC,R=301]
RewriteRule ^info/model/$ /list/8-0.html [NC,R=301]
RewriteRule ^info/report/research/$ /list/31-0.html [NC,R=301]
RewriteRule ^info/model/pathy/$ /list/37-0.html [NC,R=301]
RewriteRule ^info/lead/message/$ /list/38-0.html [NC,R=301]
RewriteRule ^info/field/discipline/$ /list/54-0.html [NC,R=301]
RewriteRule ^info/rule/safe/$ /list/64-0.html [NC,R=301]
RewriteRule ^info/rule/$ /list/2-0.html [NC,R=301]
RewriteRule ^info/lead/survey/$ /list/16-0.html [NC,R=301]
RewriteRule ^info/rule/invest/$ /list/19-0.html [NC,R=301]
RewriteRule ^info/model/plan/$ /list/33-0.html [NC,R=301]
RewriteRule ^info/report/sanhui/$ /list/39-0.html [NC,R=301]
RewriteRule ^info/field/dang/$ /list/53-0.html [NC,R=301]
RewriteRule ^info/report/$ /list/4-0.html [NC,R=301]
RewriteRule ^info/lead/arouse/$ /list/14-0.html [NC,R=301]
RewriteRule ^info/work/baogao/$ /list/28-0.html [NC,R=301]
RewriteRule ^info/ppt/other/$ /list/30-0.html [NC,R=301]
RewriteRule ^info/report/critic/$ /list/40-0.html [NC,R=301]
RewriteRule ^info/sum/zhuanti/$ /list/49-0.html [NC,R=301]
RewriteRule ^info/rule/finance/$ /list/51-0.html [NC,R=301]
RewriteRule ^info/model/huo/$ /list/58-0.html [NC,R=301]
RewriteRule ^info/field/subsume/$ /list/60-0.html [NC,R=301]
RewriteRule ^info/ppt/$ /list/5-0.html [NC,R=301]
RewriteRule ^info/rule/hr/$ /list/20-0.html [NC,R=301]
RewriteRule ^info/field/law/$ /list/22-0.html [NC,R=301]
RewriteRule ^info/sum/my/$ /list/24-0.html [NC,R=301]
RewriteRule ^info/model/study/$ /list/29-0.html [NC,R=301]
RewriteRule ^info/work/tdh/$ /list/59-0.html [NC,R=301]
RewriteRule ^info/ppt/fangan/$ /list/63-0.html [NC,R=301]
RewriteRule ^info/lead/pos/$ /list/68-0.html [NC,R=301]
RewriteRule ^info/report/xuns/$ /list/69-0.html [NC,R=301]
RewriteRule ^info/ppt/teach/$ /list/6-0.html [NC,R=301]
RewriteRule ^info/sum/$ /list/7-0.html [NC,R=301]
RewriteRule ^info/work/ghd/$ /list/10-0.html [NC,R=301]
RewriteRule ^info/report/zicha/$ /list/27-0.html [NC,R=301]
RewriteRule ^info/sum/xiangmu/$ /list/46-0.html [NC,R=301]
RewriteRule ^info/rule/law/$ /list/48-0.html [NC,R=301]
RewriteRule ^info/model/outline/$ /list/57-0.html [NC,R=301]
RewriteRule ^info/lead/year/$ /list/65-0.html [NC,R=301]
RewriteRule ^info/field/safe/$ /list/67-0.html [NC,R=301]
RewriteRule ^info/work/$ /list/3-0.html [NC,R=301]
RewriteRule ^info/lead/discus/$ /list/12-0.html [NC,R=301]
RewriteRule ^info/work/gzh/$ /list/15-0.html [NC,R=301]
RewriteRule ^info/rule/manage/$ /list/18-0.html [NC,R=301]
RewriteRule ^info/ppt/talk/$ /list/35-0.html [NC,R=301]
RewriteRule ^info/sum/bumen/$ /list/45-0.html [NC,R=301]
RewriteRule ^info/report/kaohe/$ /list/50-0.html [NC,R=301]
RewriteRule ^info/model/how/$ /list/56-0.html [NC,R=301]
RewriteRule ^info/field/analyse/$ /list/61-0.html [NC,R=301]
RewriteRule ^info/field/$ /list/9-0.html [NC,R=301]
RewriteRule ^info/lead/train/$ /list/13-0.html [NC,R=301]
RewriteRule ^info/rule/corp/$ /list/17-0.html [NC,R=301]
RewriteRule ^info/work/zdh/$ /list/26-0.html [NC,R=301]
RewriteRule ^info/ppt/upsay/$ /list/42-0.html [NC,R=301]
RewriteRule ^info/sum/xingz/$ /list/44-0.html [NC,R=301]
RewriteRule ^info/field/operate/$ /list/52-0.html [NC,R=301]
RewriteRule ^info/model/meet/$ /list/55-0.html [NC,R=301]
RewriteRule ^info/report/shuzhi/$ /list/70-0.html [NC,R=301]
RewriteRule ^info/lead/$ /list/1-0.html [NC,R=301]
RewriteRule ^info/lead/host/$ /list/11-0.html [NC,R=301]
RewriteRule ^info/work/ddh/$ /list/23-0.html [NC,R=301]
RewriteRule ^info/report/work/$ /list/25-0.html [NC,R=301]
RewriteRule ^info/model/promise/$ /list/36-0.html [NC,R=301]
RewriteRule ^info/ppt/hongse/$ /list/41-0.html [NC,R=301]
RewriteRule ^info/sum/dangwei/$ /list/43-0.html [NC,R=301]
RewriteRule ^info/rule/strategy/$ /list/47-0.html [NC,R=301]
RewriteRule ^info/field/reform/$ /list/66-0.html [NC,R=301]
RewriteRule ^info/sys/notice/$ /list/77-0.html [NC,R=301]
RewriteRule ^t/(.+?)-(.+?)\.html$ /e/action/InfoType/index\.php\?ttid=$1&page=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^tags/(.+?)-(.+?)\.html$ /e/tags/index\.php\?tagid=$1&page=$2&line=25&tempid=8 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^search/(.+?)-(.+?)\.html$ /e/search/result/index\.php\?searchid=$1&page=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^list/(.+?)-(.+?)\.html$ /e/action/ListInfo/index\.php\?classid=$1&page=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^load/(.+?)-(.+?)\.html$ /e/action/ShowInfo\.php\?id=$1&classid=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^info/link/(.+?)\.html$ /e/action/ShowSee\.php\?id=$1 [NC,L]
RewriteRule ^so/(.*)$ /e/extend/xunsearch/$1 [NC,L]
RewriteRule ^e/extend/xunsearch/index.php(.*)$ /so/$1 [NC,R=301]
</IfModule>
直到今天准备修改一下目录,与窍门网站全站的文章内页目录保持一致,其中会用到.htaccess301重定向和百度站长工具的网站改版规划,
本篇主要介绍内容页的.htaccess301重定向跳转,百度的改版规则将在另外一篇文章中介绍。
.htaccess中的[NC][R][F][L]几个标记是什么意思
NC: no case,就是说不区分大小写
R:redirect,重定向
F:forbidden,禁止访问
L:last,表示已经是最后一条规则,.htaccess文件解析即将退出
原:健身子栏目文章地址为 /beauty/ydjs/office/20130408/20366.html
跳转到 /a/201304/20366.html
在.htaccess文件中添加如下内容
RewriteEngine On
RewriteRule ^beauty/ydjs/office/(\d{6})(\d{2})/(.*)$ /a/$1/$3 [NC,R=301]
NC,R 这几个参数现在就很容易理解了,NC:忽略大小写;R:跳转形式为301
可能有的朋友对上面的规则是怎么来的,不是太理解,其实.htaccess的规则是正则形式的,所以如果说你想了解更多规则的写法,可以先看下正则表达式方面的教程。
<IfModule mod_rewrite.c>
RewriteEngine On
ErrorDocument 404 /404.html
Rewritebase /
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^info/([0-9]+)-([0-9]+)(.*)$ /info/link/$1$3 [NC,R=301]
RewriteRule ^info/link/([0-9]+)\.php$ /info/link/$1\.html [NC,R=301]
RewriteRule ^info/sys/$ /list/72-0.html [NC,R=301]
RewriteRule ^info/sys/src/$ /list/75-0.html [NC,R=301]
RewriteRule ^info/sys/ziyuan/$ /list/73-0.html [NC,R=301]
RewriteRule ^info/sys/docc/$ /list/71-0.html [NC,R=301]
RewriteRule ^info/sys/shop/$ /list/78-0.html [NC,R=301]
RewriteRule ^info/rule/party/$ /list/21-0.html [NC,R=301]
RewriteRule ^info/report/deed/$ /list/32-0.html [NC,R=301]
RewriteRule ^info/lead/comment/$ /list/34-0.html [NC,R=301]
RewriteRule ^info/field/cliques/$ /list/62-0.html [NC,R=301]
RewriteRule ^info/model/zhan/$ /list/74-0.html [NC,R=301]
RewriteRule ^info/model/$ /list/8-0.html [NC,R=301]
RewriteRule ^info/report/research/$ /list/31-0.html [NC,R=301]
RewriteRule ^info/model/pathy/$ /list/37-0.html [NC,R=301]
RewriteRule ^info/lead/message/$ /list/38-0.html [NC,R=301]
RewriteRule ^info/field/discipline/$ /list/54-0.html [NC,R=301]
RewriteRule ^info/rule/safe/$ /list/64-0.html [NC,R=301]
RewriteRule ^info/rule/$ /list/2-0.html [NC,R=301]
RewriteRule ^info/lead/survey/$ /list/16-0.html [NC,R=301]
RewriteRule ^info/rule/invest/$ /list/19-0.html [NC,R=301]
RewriteRule ^info/model/plan/$ /list/33-0.html [NC,R=301]
RewriteRule ^info/report/sanhui/$ /list/39-0.html [NC,R=301]
RewriteRule ^info/field/dang/$ /list/53-0.html [NC,R=301]
RewriteRule ^info/report/$ /list/4-0.html [NC,R=301]
RewriteRule ^info/lead/arouse/$ /list/14-0.html [NC,R=301]
RewriteRule ^info/work/baogao/$ /list/28-0.html [NC,R=301]
RewriteRule ^info/ppt/other/$ /list/30-0.html [NC,R=301]
RewriteRule ^info/report/critic/$ /list/40-0.html [NC,R=301]
RewriteRule ^info/sum/zhuanti/$ /list/49-0.html [NC,R=301]
RewriteRule ^info/rule/finance/$ /list/51-0.html [NC,R=301]
RewriteRule ^info/model/huo/$ /list/58-0.html [NC,R=301]
RewriteRule ^info/field/subsume/$ /list/60-0.html [NC,R=301]
RewriteRule ^info/ppt/$ /list/5-0.html [NC,R=301]
RewriteRule ^info/rule/hr/$ /list/20-0.html [NC,R=301]
RewriteRule ^info/field/law/$ /list/22-0.html [NC,R=301]
RewriteRule ^info/sum/my/$ /list/24-0.html [NC,R=301]
RewriteRule ^info/model/study/$ /list/29-0.html [NC,R=301]
RewriteRule ^info/work/tdh/$ /list/59-0.html [NC,R=301]
RewriteRule ^info/ppt/fangan/$ /list/63-0.html [NC,R=301]
RewriteRule ^info/lead/pos/$ /list/68-0.html [NC,R=301]
RewriteRule ^info/report/xuns/$ /list/69-0.html [NC,R=301]
RewriteRule ^info/ppt/teach/$ /list/6-0.html [NC,R=301]
RewriteRule ^info/sum/$ /list/7-0.html [NC,R=301]
RewriteRule ^info/work/ghd/$ /list/10-0.html [NC,R=301]
RewriteRule ^info/report/zicha/$ /list/27-0.html [NC,R=301]
RewriteRule ^info/sum/xiangmu/$ /list/46-0.html [NC,R=301]
RewriteRule ^info/rule/law/$ /list/48-0.html [NC,R=301]
RewriteRule ^info/model/outline/$ /list/57-0.html [NC,R=301]
RewriteRule ^info/lead/year/$ /list/65-0.html [NC,R=301]
RewriteRule ^info/field/safe/$ /list/67-0.html [NC,R=301]
RewriteRule ^info/work/$ /list/3-0.html [NC,R=301]
RewriteRule ^info/lead/discus/$ /list/12-0.html [NC,R=301]
RewriteRule ^info/work/gzh/$ /list/15-0.html [NC,R=301]
RewriteRule ^info/rule/manage/$ /list/18-0.html [NC,R=301]
RewriteRule ^info/ppt/talk/$ /list/35-0.html [NC,R=301]
RewriteRule ^info/sum/bumen/$ /list/45-0.html [NC,R=301]
RewriteRule ^info/report/kaohe/$ /list/50-0.html [NC,R=301]
RewriteRule ^info/model/how/$ /list/56-0.html [NC,R=301]
RewriteRule ^info/field/analyse/$ /list/61-0.html [NC,R=301]
RewriteRule ^info/field/$ /list/9-0.html [NC,R=301]
RewriteRule ^info/lead/train/$ /list/13-0.html [NC,R=301]
RewriteRule ^info/rule/corp/$ /list/17-0.html [NC,R=301]
RewriteRule ^info/work/zdh/$ /list/26-0.html [NC,R=301]
RewriteRule ^info/ppt/upsay/$ /list/42-0.html [NC,R=301]
RewriteRule ^info/sum/xingz/$ /list/44-0.html [NC,R=301]
RewriteRule ^info/field/operate/$ /list/52-0.html [NC,R=301]
RewriteRule ^info/model/meet/$ /list/55-0.html [NC,R=301]
RewriteRule ^info/report/shuzhi/$ /list/70-0.html [NC,R=301]
RewriteRule ^info/lead/$ /list/1-0.html [NC,R=301]
RewriteRule ^info/lead/host/$ /list/11-0.html [NC,R=301]
RewriteRule ^info/work/ddh/$ /list/23-0.html [NC,R=301]
RewriteRule ^info/report/work/$ /list/25-0.html [NC,R=301]
RewriteRule ^info/model/promise/$ /list/36-0.html [NC,R=301]
RewriteRule ^info/ppt/hongse/$ /list/41-0.html [NC,R=301]
RewriteRule ^info/sum/dangwei/$ /list/43-0.html [NC,R=301]
RewriteRule ^info/rule/strategy/$ /list/47-0.html [NC,R=301]
RewriteRule ^info/field/reform/$ /list/66-0.html [NC,R=301]
RewriteRule ^info/sys/notice/$ /list/77-0.html [NC,R=301]
RewriteRule ^t/(.+?)-(.+?)\.html$ /e/action/InfoType/index\.php\?ttid=$1&page=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^tags/(.+?)-(.+?)\.html$ /e/tags/index\.php\?tagid=$1&page=$2&line=25&tempid=8 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^search/(.+?)-(.+?)\.html$ /e/search/result/index\.php\?searchid=$1&page=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^list/(.+?)-(.+?)\.html$ /e/action/ListInfo/index\.php\?classid=$1&page=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^load/(.+?)-(.+?)\.html$ /e/action/ShowInfo\.php\?id=$1&classid=$2 [NC,L]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^info/link/(.+?)\.html$ /e/action/ShowSee\.php\?id=$1 [NC,L]
RewriteRule ^so/(.*)$ /e/extend/xunsearch/$1 [NC,L]
RewriteRule ^e/extend/xunsearch/index.php(.*)$ /so/$1 [NC,R=301]
</IfModule>
新闻资讯 更多
- 【帝国cms教程】帝国CMS模板变量$GLOBALS[navclassid]用法分析04-03
- 【帝国cms教程】鲜为人知帝国CMS内容页调用上一篇和下一篇的精华方法汇总04-03
- 【帝国cms教程】怎么快速找出帝国CMS数据库配置文件路径及迁移网站后修改技巧!04-03
- 【帝国cms教程】帝国CMS模板$GLOBALS[navclassid]用法详解04-03
- 【帝国cms教程】帝国cms 7.5版列表页分页样式修改笔记04-02
- 【帝国cms教程】解决帝国CMS搜索页面模板不支持灵动标签和万能标签的方法04-02
- 【帝国cms教程】帝国CMS只备份栏目和模板的方法04-02
- 【帝国cms教程】帝国CMS怎样删除清空数据库记录?04-02
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法