首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

三种方法兑现URL重写

2012-11-20 
三种方法实现URL重写URL重写,就把动态URL静态化,便于搜索引擎爬虫抓取你的动态网页举例/product.jsp?id10

三种方法实现URL重写
URL重写,就把动态URL静态化,便于搜索引擎爬虫抓取你的动态网页

举例
/product.jsp?id=1001
/product.jsp?id=1002
/product.jsp?id=1003

重写后,可以用
/product/1001.html
/product/1002.html
/product/1003.html


一、过滤器 用 urlReweite的类库

修改web.xml增加过滤器,然后配置个过滤规则

web.xml修改部分



二、使用Apache
# 去掉这个前面的#,启用它
LoadModule rewrite_module modules/mod_rewrite.so

<VirtualHost _default_:80>
# 其它的配置数据

RewriteEngine On
# 下面三行实现动态解析
RewriteRule ^/product/(\d+).html$ /product.jsp?id=$1 [L,PT]
</VirtualHost>

三、使用404页面跳转

web.xml修改部分

 

热点排行