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>
    

      

  • 相关阅读:
    Python之路【第二十九篇】:面向对象基础
    Python之路【第二十八篇】:生成器与迭代器
    爬虫实战---爬取猫眼电影
    Selenium库详解
    PyQuery库详解
    BeautifulSoup解析库详解
    深浅拷贝的使用场景分析
    关于大数据量下Core Data的数据迁移
    IOS5中的新增方法详解
    自定义UISearchBar
  • 原文地址:https://www.cnblogs.com/xie-xiao-chao/p/8351854.html
Copyright © 2011-2022 走看看