小s货又想挨c了叫大声点小说,日韩成av人片在线观看,大肉楱征服岳乱妇小说,gogogo高清在线观看视频电影

合肥網站建設
文章閱讀
網建技巧
優化技巧
網建問題
謹宸新聞
行業新聞

首頁 > 合肥網站建設 > 正文

如何利用apache重寫靜態頁面

發布時間:2011/05/05字體:
摘要:如何利用apache重寫靜態頁面,apache重寫靜態頁面,如何開啟apache重寫,apache重寫規,本技巧重點介紹在apache中如何開啟apache重寫規則,并實例講解了apache重寫靜態頁面案例。具體方法如下:apache配置文件httpd.conf中加載:mod_rewrit

本技巧重點介紹在apache中如何開啟apache重寫規則,并實例講解了apache重寫靜態頁面案例

 具體方法如下:
apache配置文件httpd.conf中加載:LoadModule rewrite_module modules/mod_rewrite.so

兩種方法重寫
第一種:
   
        RewriteEngine On
            RewriteRule ^\/content/(.*)_(.*)htm$ /test.php?q=$1&a=$2
   

介紹:這種方法,比如鏈接文件:test.php,這樣鏈接的頁面實際請求的頁面是:test.php?q=2303&a=ok.前面的content是偽裝的

例子:
a.html :
    test.php
test.php :
            echo $_GET["q"];//結果是2303
        echo $_GET["a"];//結果是ok.(有一個.)
    ?>



第二種:
#這里的content就是要偽裝的文件夾名稱
    ForceType application/x-httpd-php


介紹:這種方法實際意義上說不是偽裝content文件夾,而是讓服務器解釋content文件,沒有拓展名的content文件.

例子:
a.html :
    test.php
有一個content的文件,沒有拓展名
content :
                $fields = explode('/', $_SERVER['REQUEST_URI']);
            $id_pos = array_search('content', $fields);
            if( $id_pos !== false ){
                $c_id = $fields[ $id_pos + 1 ];
                $a_id = $fields[ $id_pos + 2 ];
            }
            if( $a_id ){
                $_GET['aid'] = $a_id;
                $_GET['cid'] = $c_id;
                require_once('showarticle.php');
            }
    ?>
test.php :
            echo $_GET['aid'];//結果是445
        echo $_GET['cid'];//結果是0
    ?>
   


下面是一些值得學習的apache重寫規則:
RewriteEngine On
RewriteRule index.html$ index.php
RewriteRule ^([a-zA-Z]+)/$ index.php?en=$1
RewriteRule ^([a-zA-Z]+)$ index.php?en=$1
RewriteRule ^([0-9]+)\.html$ view.php?id=$1
RewriteRule ^([0-9]+)_([a-zA-Z0-9]+)\.html$ view.php?id=$1&user=$2

    RewriteRule ^/([0-9]+)\.htm$ /test.php?id=$1
    RewriteRule ^/newsview-([0-9]+)_([0-9]+)_([0-9]+)_([a-z]+)\.htm$ /test.php?type=$1&id=$2&page=$3&user=$4
    RewriteRule ^/test\.htm$ /test.php
    #RewriteRule ^/(.*)\.htm$ /test.php?add=$1
    RewriteRule new.html$ a.php
    RewriteRule ^/content/([a-z]+)_([0-9]+)\.html$ /a.php?who=$1&$page=$2
    RewriteRule ^/([0-9]?).html$ /a.php?who=$1


RewriteEngine On
RewriteRule index.html$ index.php
RewriteRule ^([0-9]+)\.html$ read.php?id=$1
RewriteRule ^([0-9]+)_([0-9]+)\.html$ read.php?id=$1&p=$2

RewriteRule industry.html$ info.php?type=1
RewriteRule design.html$ info.php?type=2
RewriteRule interview.html$ info.php?type=3
RewriteRule exhibition.html$ info.php?type=4
RewriteRule home.html$ info.php?type=5
RewriteRule help.html$ info.php?type=6
RewriteRule bbs.html$ info.php?type=7
RewriteRule 99cad.html$ info.php?type=8
RewriteRule recruitment.html$ info.php?type=9


RewriteRule index.html$ index.php
RewriteRule ^([0-9]+)\.html$ view.php?id=$1

RewriteRule index.html$ index.php
RewriteRule ^([0-9]+)\.html$ read.php?id=$1
RewriteRule ^([0-9]+)_([0-9]+)\.html$ read.php?id=$1&p=$2

RewriteRule industry.html$ info.php?type=1
RewriteRule design.html$ info.php?type=2
RewriteRule interview.html$ info.php?type=3
RewriteRule exhibition.html$ info.php?type=4
RewriteRule home.html$ info.php?type=5
RewriteRule help.html$ info.php?type=6
RewriteRule bbs.html$ info.php?type=7
RewriteRule d.html$ info.php?type=8
RewriteRule recruitment.html$ info.php?type=9
本文標題:如何利用apache重寫靜態頁面
本文網址:http://www.hbggty.com/wangjianjiqiao/48.html
原創網址:合肥網絡公司<謹宸科技> 版權所有,轉載請注明出處,并以鏈接形式鏈接網址:www.hbggty.com
文章標簽:apache靜態頁面
 上一篇:如何做好網站鏈接
 下一篇:貢獻05年學習javascript和div+css時候總結的一些小技巧
主站蜘蛛池模板: 邳州市| 阜阳市| 临夏市| 无棣县| 海阳市| 隆化县| 美姑县| 黑河市| 十堰市| 大城县| 鸡泽县| 海兴县| 林周县| 宜良县| 德阳市| 上思县| 平江县| 万安县| 都安| 渭源县| 平凉市| 独山县| 宁津县| 广南县| 华亭县| 梅州市| 靖西县| 祁东县| 诸暨市| 临猗县| 镇巴县| 南江县| 广饶县| 崇州市| 凤阳县| 织金县| 南靖县| 昭苏县| 黄梅县| 塘沽区| 娄底市|