1 ͨϵͳСǷΪ̬ URL ̬ Ĵ򿪻ر

2 ܶԷҪ󣬶ûҪ Web Ӧ Rewrite ҪȨ޲ſʹáûҪĿռ̽ѯռǷ֧ Rewrite ԼǷֶ֧վĿ¼ .htaccess ļֻURL ̬ ܲŻЧ

3  URL ̬ ̳һЩӻ http://www.demo.com/category-1.html ʽķֻ֧δúãЩӻ֡ҳ޷ʾĴϢ̳޷ʡ޷ʵʱ̨ر URL ̬ ܣ̳ɻָ״̬ 

urlrewriteܵԼڿ˹֮ǰ Web ѡӦĻ÷пɷ޷߹Ч½ṩ Apache  Zeus ÷IIS  Web ɸԭ޸ġ


----- Apache Web Serverû

ȷʹõ Apache 汾Ƿ mod_rewrite ģ顣 

Apache 1.x û conf/httpd.conf Ƿδ룺 

LoadModule rewrite_module     libexec/mod_rewrite.so
AddModule mod_rewrite.c

Apache 2.x û conf/httpd.conf Ƿһδ룺 

LoadModule rewrite_module     modules/mod_rewrite.so

ڣôļͨ conf/httpd.confм´롣ʱע⣬վʹͨ壬ؼӵã <VirtualHost> ȥⲿ޷ʹáĺúȻ Apache  

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/index\.html$ $1/index.php
RewriteRule ^(.*)/category-([0-9]+)\.html$ $1/category.php?id=$2
RewriteRule ^(.*)/category-([0-9]+)-([0-9]+)\.html$ $1/category.php?id=$2&area=$3
RewriteRule ^(.*)/category-([0-9]+)-([0-9]+)-([1-9999]+)\.html$ $1/category.php?id=$2&area=$3&page=$4
RewriteRule ^(.*)/view-([0-9]+)\.html$ $1/view.php?id=$2
RewriteRule ^(.*)/about-([0-9]+)\.html$ $1/about.php?id=$2
</IfModule>


--------Apache Web Serverû

ڿʼ֮ǰѯĿռ̣ռǷ֧ Rewrite ԼǷֶ֧վĿ¼ .htaccess ļ򼴱㰴ķúˣҲ޷ʹá 

վĿ¼Ƿ .htaccess ļڣֹļWin32 ϵͳ£޷ֱӽ .htaccess ļԴ䱾Ŀ¼пһݡ

--------IIS Web Serverû

 IIS  Isapi ɸѡûпʵiisα̬ģļµģ飬ɸѡΪ Rewrite ִļѡ Rewrite.dll  IIS httpd.ini Ѿúã£ 

[ISAPI_Rewrite]

# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP

RewriteRule ^(.*)/index\.html\?*(.*)$ $1/index.php
RewriteRule ^(.*)/category-([0-9]+)\.html\?*(.*)$ $1/category\.php\?id=$2
RewriteRule ^(.*)/category-([0-9]+)-([0-9]+)\.html\?*(.*)$ $1/category\.php\?id=$2&area=$3
RewriteRule ^(.*)/category-([0-9]+)-([0-9]+)-([1-9999]+)\.html\?*(.*)$ $1/category\.php\?id=$2&area=$3&page=$4
RewriteRule ^(.*)/view-([0-9]+)\.html\?*(.*)$ $1/view\.php\?id=$2
RewriteRule ^(.*)/about-([0-9]+)\.html\?*(.*)$ $1/about\.php\?id=$2