当前位置: 代码迷 >> Java Web开发 >> apache url rewite有关问题
  详细解决方案

apache url rewite有关问题

热度:576   发布时间:2016-04-17 13:49:53.0
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
  相关解决方案