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

兩種方法重寫
先進(jìn)種:
" />

国产毛片一区二区三区女同性恋_日韩欧洲区精品一区二区_乱人伦中文视频在线观看_五月天在线视频国产在线下载_挺进邻居丰满少妇的身体_国产乱子伦精品免费视频_国产精品无码一区二区A∨白浆_操女生在线观看免费观看视频_影音先锋av每日最新久久_婷婷五月精品综合一区

186-0984-0880
 
如何利用apache重寫靜態(tài)頁(yè)面
日期:09-29 瀏覽次數(shù):19


本技巧重點(diǎn)介紹在apache中如何開啟apache重寫規(guī)則,并實(shí)例講解了apache重寫靜態(tài)頁(yè)面案例

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

兩種方法重寫
先進(jìn)種:
   
        RewriteEngine On
            RewriteRule ^//content/(.*)_(.*)htm$ /test.php?q=$1&a=$2
   

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

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



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


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

例子:
a.html :
    test.php
有一個(gè)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'];//結(jié)果是445
        echo $_GET['cid'];//結(jié)果是0
    ?>
   


下面是一些值得學(xué)習(xí)的apache重寫規(guī)則:
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

← 上一篇 下一篇 → 返回首頁(yè)
如有意向,請(qǐng)聯(lián)系我們的客戶經(jīng)理
我們會(huì)根據(jù)您的需求為你制定詳細(xì)的解決方案
在線咨詢 or 撥打業(yè)務(wù)熱線:186-0984-0880
在線咨詢
熱線電話
解決方案
掃一掃

掃一掃
關(guān)注新圖聞科技

全國(guó)咨詢熱線
186-0984-0880

返回頂部