1、.htaccess文件

RewriteEngine on #开启Rewrite功能
RewriteRule test.html test.php
RewriteRule test2.html test2.php
RewriteRule ^([\w\W]+).html$ test.php?t=$1
#([\w\W]+)代表任意字符
RewriteRule ^test/([0-9]+)$ test.php?id=$1
#([0-9]+)代表数字
RewriteRule ^([\w\W]+)/([\w\W]+)$ test.php?t=$1&id=$2
#带多个参数的连接

#定义404页面
ErrorDocument 404 /zhiyimei/404.php

2、test.php //显示动态获取的变量值。

<?php
$t=$_GET["t"];
$id=$_GET["id"];
if (!empty($t)) {
echo $t;
}
echo “<br />”;
if (!empty($id)) {
echo $id;
}
?>

3、test2.php //重写后的URL链接
<a href=”AboutUs.html”>AboutUs</a>
<a href=”ContactUs.html”>ContactUs</a>
<a href=”SiteMap.html”>SiteMap</a>
<a href=”test/1″>1</a>
<a href=”test/2″>2</a>
<a href=”test/3″>3</a>
<a href=”AboutUs/1″>AboutUs-1</a>
<a href=”ContactUs/2″>ContactUs-2</a>
<a href=”SiteMap/3″>SiteMap-3</a>