我有一個嵌入式Jetty服務器,我想直接從http://localhost:8080/到https://localhost:4433/請求我該怎麼做?我試過這個:Jetty使用重寫將HTTP重定向到HTTPS
// Set up rewriting (HTTP -> HTTPS)
RewriteHandler rewrite = new RewriteHandler();
RedirectPatternRule redirect = new RedirectPatternRule();
redirect.setPattern("http://localhost:8080/*");
redirect.setLocation("https://localhost:4433/");
rewrite.addRule(redirect);
並將其添加到我的處理程序中,但它不起作用。我知道規則就像
RewriteHandler rewrite = new RewriteHandler();
RedirectPatternRule redirect = new RedirectPatternRule();
redirect.setPattern("/redirect/*");
redirect.setLocation("/redirected");
rewrite.addRule(redirect);
工作100%,但有沒有辦法匹配完整的URL?
完美,前者完美無缺! – Display