URL Landing on a folder

Splash Forums Rewrite Users URL Landing on a folder

This topic contains 8 replies, has 3 voices, and was last updated by  detestable 5 years, 3 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #18465

    detestable
    Participant

    Let’s say we have this folder layout :

    src/main/webapp/folder/index.xhtml

    src/main/webapp/folder/test.xhtml

    And in rewrite configuration :

    .addRule(Join.path("/folder").to("/folder/index.xhtml"))

    .addRule(Join.path("/folder/test").to("/folder/test.xhtml"))

    When I hit http://localhost:8080/ctx/folder I get a 301 to http://localhost:8080/ctx/folder/

    It looks like something (may be JSF?) unallow me to land on a folder without a trailing slash.

    Is there a way for me to access my ressource with http://localhost:8080/ctx/folder ?

    #22682

    Hiya,

    A little more information might help figure this out :)

    What server are you using? Do you have any other URL-rewriting configured? Can you reproduce this in other applications on this server? Could you attach an app that reproduces this?

    I doubt JSF would be involved since Rewrite should be intercepting things first, so this is probably a configuration in the container, or in another filter.

    ~Lincoln

    #22683

    I saw similar behavior once on an application running on AS7. It was a very simply JSF app with PrettyFaces 3.3.3 and a URL mapping for /something. I never figured out what was wrong and who was sending the redirect. I doubt that it was PrettyFaces’ fault. I “fixed” it back then by appending a / to my mapping pattern which solved the problem.

    #22684

    detestable
    Participant
    #22685

    Interesting. I just tested your app on AS7. I got nearly the same behavior. The only difference is that I’m getting a 302 instead of a 301.

    #22686

    Ah, I found something. It seems to depend on whether the requested virtual path exists on in the web resources.

    I did this:

    http://localhost:8080/RewriteTest/simpletest ----> 404

    But if I add an empty directory called simletest to the root directory of my web app the same requests results in:

    http://localhost:8080/RewriteTest/simpletest ----> 302 to: http://localhost:8080/RewriteTest/simpletest/

    Strange, isn’t it. Seems to be a container specific thing.

    #22687

    Same behavior in Tomcat 7.0.22. Seems like others are running into this problem as well:

    http://stackoverflow.com/questions/2815986/where-does-tomcat-append-to-directory-paths

    #22688

    I did some research on this. The guys on tomcat-users wrote that this behavior has been implemented because it is “required by the HTTP spec”. I don’t fully understand why. But it seems like most of the containers implement something similar.

    See:

    http://tomcat.10.n6.nabble.com/How-to-prevent-Tomcat-redirect-my-request-td2122751.html

    So I guess the only option for you would be to either append the trailing slash to your virtual URL (the path() part of your join) or you simply rename the directory in your webapp to something else to prevent the name clash.

    Christian

    #22689

    detestable
    Participant

    Strange behavior indeed, may be some JEE spec’s requires this behavior I can’t see why it would be HTTP specific.

    Thanks for the researches, I think I’ll put everything in a root directory like “faces” and create rules to use the URLs I really want!

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

Comments are closed.