• apache 伪静态 .htaccess


    虽然网上有很多教程,但是我在这里进行简单对我用到的总结一下。

    加载Rewrite模块:

    在conf目录下httpd.conf中找到

    LoadModule rewrite_module modules/mod_rewrite.so

    这句,去掉前边的注释符号“#”,或添加这句。

    .htacess文件,开头内容如下:

    RewriteEngine on

    RewriteEngine on是代表开启rewrite。在正是写规则前,先为大家讲一下重写中设计到的特殊字符的含义。和普通正则是通用的!

    *代表前面0或更多个字符

    +代表前面1或更多个字符

    ?代表前面0或1个字符

    ^代表字符串的开始位置

    $代表字符串结束的位置

    .为通配符,代表任何字符

    将跟在其后的字符还原为字符本身,例如“+”代表的就是“+”,而非其它意思。

    ^在方括号里表示非的意思。例如[^.]代表非通配符。

    在这里,我给大家列出一个我用到的.htacess。

    RewriteEngine on
    RewriteRule index.htm$  dashboard.php
    RewriteRule ing-([0-9]{1,}).html$ activity_ing.php?page=$1
    RewriteRule ago-([0-9]{1,}).html$ activity_ago.php?page=$1
    RewriteRule mine-([0-9]{1,}).html$ activity_mine.php?page=$1
    RewriteRule den-([0-9]{1,}).html$ dentify.php?page=$1
    RewriteRule after-([0-9]{1,}).html$ after_activity.php?page=$1
    RewriteRule news-([0-9]{1,}).html$ news.php?article_id=$1
    RewriteRule new-([0-9]{1,}).html$ news_after.php?article_id=$1
    RewriteRule yijian.html$ yijian.php
    RewriteRule byebye.html$ byebye.php

    如果网站做改版,导致URL结构发生了变化,怎么办?

    答案很简单,我们可以利用.htacess文件,通过写rewrite规则,将老的URL 301到新的URL上。

    转载请注明出处:http://www.cnblogs.com/yydcdut/p/3688346.html

  • 相关阅读:
    synergy一个鼠标键盘控制多台电脑
    matlab 画图参考小程序
    基于centos7的真实机环境下安装 vmware workstastion
    mapreduce运行原理及YARN
    mybatis_resultMap(2)
    (第6天)mybatis_resultMap(1)
    mybatis动态SQL--传入参数为集合,数组类型
    mybatis动态SQL--Trim --Where
    mybatis动态SQL--if--choose
    (第5天)mybatis接口方法入参类型
  • 原文地址:https://www.cnblogs.com/yydcdut/p/3688346.html
Copyright © 2020-2023  润新知