zoukankan      html  css  js  c++  java
  • Apache服务器301重定向去掉index.html和index.php尾巴

    在做优化网站的时候,会考虑到网站整站的集权,通常市面上常见的帝国cms 织梦cms等都会自带首页index.html等文件,为了避免蜘蛛在爬行过程中权重的流失,导致重复收录首页页面,作为一枚站长,必须学会集中权重的策略,下面就为大家简单的介绍下一个集中权重的方式:

    考虑到网站可以生成静态,首先,让网站优先访问 index.html

    Apache服务器301重定向去掉index.html和index.php

    之后考虑:去掉 .html 和 .php。

    利用.htaccess

    1. 复制代码 
    2. <IfModule mod_rewrite.c> 
    3.  RewriteEngine on 
    4.  RewriteBase / 
    5.  RewriteCond %{REQUEST_FILENAME} !-d 
    6.  RewriteCond %{REQUEST_FILENAME} !-f 
    7.  RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L] 
    8. </IfModule> 

    修改:

    1. <IfModule mod_rewrite.c> 
    2.  RewriteEngine on 
    3.  RewriteBase / 
    4.  RewriteCond %{HTTP_HOST} ^www.yn37wang.com$ [NC] 
    5.  RewriteCond %{REQUEST_URI} ^/index.html [NC] 
    6.  RewriteRule .* / [R=301,L] 
    7.  RewriteCond %{REQUEST_FILENAME} !-d 
    8.  RewriteCond %{REQUEST_FILENAME} !-f 
    9.  RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L] 
    10. </IfModule> 

    即可。

    广州vi设计公司http://www.maiqicn.com 我的007办公资源网 https://www.wode007.com

    具体:

    1. RewriteEngine On 
    2. RewriteBase / 
    3.  
    4. # .htaccess伪静态301去掉index.html尾巴 
    5. RewriteCond %{HTTP_HOST} ^www.qdonger.com$ [NC] 
    6. RewriteCond %{REQUEST_URI} ^/index.html [NC] 
    7. RewriteRule .* / [R=301,L] 
    8.  
    9. # .htaccess伪静态301去掉index.php尾巴 
    10. RewriteCond %{HTTP_HOST} ^www.qdonger.com$ [NC] 
    11. RewriteCond %{REQUEST_URI} ^/index.php [NC] 
    12. RewriteRule .* / [R=301,L] 
     
     
  • 相关阅读:
    [Next] 六.next的优化
    [Next] 五.next自定义内容
    Mac解决端口占用
    [Next] 四.在next中引入redux
    [Next] 服务端渲染知识补充
    [Next] 三.next自定义服务器和路由
    哪些使用UDP、TCP、IP协议
    IDEA配置git
    ssm整合配置
    git传输远程仓库
  • 原文地址:https://www.cnblogs.com/ypppt/p/13653461.html
Copyright © 2011-2022 走看看