【发布时间】:2013-08-22 09:33:13
【问题描述】:
我在 tomcat 上有一个 web 应用程序 http://localhost:8080/WebApp/
我已经配置了 Apache 2 (mod_proy),以便 localhost 可以直接访问 Web 应用程序,无需端口和名称:例如 http://localhost
<VirtualHost localhost:80>
ProxyPreserveHost On
ProxyPass / http://localhost:8080/WebApp/
ProxyPassReverse / http://localhost:8080/WebApp/
</VirtualHost>
http://localhost 上正确显示了 index.html。
但是如果一个 servlet 重定向:
@WebServlet(description = "...", urlPatterns = { "/login" })
public class LoginServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
response.sendRedirect("a.html");
}
}
我使用 URL http://localhost/login - 我被重定向到 http://localhost/WebApp/a.html
如何正确重定向到http://localhost/a.html?
【问题讨论】:
-
您需要以 root 身份部署您的应用程序。我在下面添加了操作方法。
标签: java apache tomcat redirect mod-proxy