zoukankan      html  css  js  c++  java
  • 通过htaccess使用伪静态

    利用htaccess文件可以很好的进行站点伪静态,并且形成的目标地址与真正的静态页面几乎一模一样,如abc.html等,伪静态可以非常好的结合SEO来提高站点的排名,并且也能给人一种稳定的印象。

    若要通过htaccess使用伪静态,则必须空间商支持Rewrite模块,该模块负责URL的重写。否则即便是设置好了,也无法使用,并且还有可能出现500错误。

    PHP检测是否支持Rewrite模块:

            $result = apache_get_modules();
            if(in_array('mod_rewrite', $result)) {
                    echo '支持';
            } else {
                    echo '不支持';
            }

    .htaccess文件常见代码

    ErrorDocument 404 /404.html
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^xxc.com [NC]
    RewriteRule ^(.*)$ http://www.xxc.com/$1 [L,R=301]
    
    RewriteRule ^index.html$ /Index.php [QSA]
    
    ##################################################
    RewriteRule ^ajaxwww.html$ /Index.php?Module=Ajax&Action=Index [QSA]
    #自定义页面START
    RewriteRule ^about/map.html$ /Index.php?Module=About&Action=Map [QSA]
    RewriteRule ^about/([a-z]+).html$ /Index.php?Module=About&Action=Help&Alias=$1 [QSA]
    RewriteRule ^about/([0-9]+).html$ /Index.php?Module=About&Action=HelpInfo&ID=$1 [QSA]
    #自定义页面END
    
    #验证码
    RewriteRule ^code/pic.jpg$ /Plugins/Code/Class.DoCode.php [QSA]
    #SEO
    RewriteRule ^robots.txt$ /robots.php [QSA]
    RewriteRule ^sitemap.xml$ /sitemap.php [QSA]
    
    </IfModule>
    

      

  • 相关阅读:
    目标检测:YOLOV2
    目标检测:YOLOV1
    格拉姆矩阵(Gram matrix)详细解读
    Java 线程Thread.Sleep详解
    luogu2429 制杖题
    luogu2441 角色属性树
    luogu2398 SUM GCD
    luogu2303 [SDOI2012] Longge的问题
    luogu2054 洗牌 同余方程
    线性同余方程
  • 原文地址:https://www.cnblogs.com/xie-xiao-chao/p/8351854.html
Copyright © 2011-2022 走看看