三种方法实现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修改部分