读书人

apache url rewite有关问题

发布时间: 2011-12-06 23:05:08 作者: rapoo

apache url rewite问题
我的目的,想实现类似www.163.com/blog/username

比如我访问http://www.163.com/myspace/username

forword到 http://www.163.com/myspace/index.jsp?name=username

谁会写... 帮忙了

[解决办法]
写一个过滤器,过滤/myspace/* 如果是http://www.163.com/myspace/username这种形式的话就跳转到 http://www.163.com/myspace/index.jsp?name=username页。过滤器应先判断是否是index.jsp,否则会死循环。
[解决办法]
如果时静态的
Redirect [status] URL-path URL

Redirect /myspace/username http://www.163.com/myspace/index.jsp?name=username


如果时动态的
RedirectMatch [status] regex URL
Redirect /myspace/(.*) http://www.163.com/myspace/index.jsp?name=$1

读书人网 >Java Web开发

热点推荐