成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

如何利用apache重寫靜態(tài)頁面

2023-05-18    分類: 網(wǎng)站建設

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

具體方法如下:
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"];//結(jié)果是2303
echo $_GET["a"];//結(jié)果是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'];//結(jié)果是445
echo $_GET['cid'];//結(jié)果是0
?>

下面是一些值得學習的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

當前標題:如何利用apache重寫靜態(tài)頁面
URL分享:http://jinyejixie.com/news21/259971.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站品牌網(wǎng)站設計、品牌網(wǎng)站制作、網(wǎng)站導航、軟件開發(fā)做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設
香格里拉县| 宣恩县| 富顺县| 额尔古纳市| 光山县| 长沙市| 靖安县| 庄河市| 塘沽区| 合阳县| 景德镇市| 简阳市| 垣曲县| 商南县| 大安市| 中超| 东安县| 无极县| 星子县| 榆中县| 基隆市| 临清市| 贵州省| 尉犁县| 宁河县| 大石桥市| 武穴市| 汕头市| 鄄城县| 巩义市| 鹤壁市| 如皋市| 铜陵市| 安达市| 建昌县| 安西县| 禄丰县| 义马市| 皮山县| 青神县| 嵊泗县|