Hi,

I just installed tomcat 8 and used the RewriteValve to forward some old
URLs on my new tomcat8 webapp. I had an issue for URIs targeting a
folder: If there is no "/" at the end of the URI, the rewritten URI is
visible for the client browser (302 redirection).
Example :
http://myhost.com/myFolder => http://myhost.com/rewriteTrick/myFolder/
instead of
http://myhost.com/myFolder => http://myhost.com/myFolder/

I made a custom patch on RewriteValve to solve it. I would like to know if 
it'll be corrected on next releases. (i tried on 8.0.18 but there is still the 
issue)

Regards,

Jeremie Barthes
Oodrive France



Between lines 480 and 500 :

                  boolean folderRedirect = false;
                    try{
                        request.getMappingData().recycle();
                            
request.getConnector().getService().getMapper().map(request.getCoyoteRequest().serverName(),
 request.getCoyoteRequest().requestURI(),
                                    null, request.getMappingData());
                            
if(request.getMappingData().redirectPath.toString()!=null){
                                folderRedirect = true;
                            }
                    } catch (Exception e){
                        //ignore
                    }

                    request.getMappingData().recycle();
                    // Reinvoke the whole request recursively
                    try {
                        
request.getConnector().getProtocolHandler().getAdapter().service
                        (request.getCoyoteRequest(), 
response.getCoyoteResponse());
if(folderRedirect && response.getCoyoteResponse().getStatus() == 302){
                                
if(!request.getCoyoteRequest().requestURI().getByteChunk().toString().endsWith("/")){
                                        String requestParam = request.getQueryString() == 
null ? "" : '?' + request.getQueryString();
                                        response.setHeader("Location", 
request.getCoyoteRequest().requestURI().getByteChunk().toString() + '/' + requestParam);
                                }
                        }
                    } catch (Exception e) {
                        // This doesn't actually happen in the Catalina adapter 
implementation
                    }






---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to