Problem with URL rewrite

Splash Forums PrettyFaces Users Problem with URL rewrite

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Christian Kaltepoth 6 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17876

    giorgiofran2
    Participant

    Hi all,

    I have a question on Url rewrite.

    I thought (or hoped), reading the documentation, that I could do something like the following:

    while receiving an URL like http://www.example.com/context/faces/index_3.xhtml, show something like http://www.newsite.com/ in the browser address bar.

    I have tried with the following instruction: <rewrite url=”http://www.newsite.com/&#8221; />, but i got an url like http://www.example.com/context/http%3A//www.newsite.com/http%3A//www.newsite.com/http%3A//www.(…continued many times).

    If I use a statement like: rewrite match=”/faces/(w+).(w+)” url=”http://www.newsite.com/$1.$2&#8243; I see the following url in the address bar:

    http://www.example.com/contexthttp://www.newsite.com/index_3.xhtml.

    In general it seem like that I can change/rewrite only those parts of the url after the context. Am i right or am I missing something?

    Thans in advance,

    Giorgio

    P.S.

    I’m using PrettyFace 3.2.0 for JSF 2.0

    #20719

    Hey Giorgio,

    there seems to be a problem with rewrite rules when using the url attribute in PrettyFaces 3.2.0. A user reported something similar yesterday. We did a major refactoring regarding URL encoding in this version and I think there is something wrong with this new code.

    What exactly is your requirement? Do you want to change the hostname or do you want to rewrite just the part of the URL that is relative to the context path? If you want to change the hostname I suggest to switch to PrettyFaces 3.1.0. This should work in this version without problems. In the other case you could use the substitute attribute instead of the url attribute as it works relative to the context path. See the documentation for details.

    I’ll come back to you as soon as I find some time to take a deeper look at this issue.

    Christian

    #20720

    giorgiofran2
    Participant

    I need to do both things.

    1) at present my server responds showing the IP address, so I’d like to show the internet address (that one that the user inserted).

    2) The user would like to see always the same address (i.e. http://www.myDomain.net) without the context part.

    I have tried with 3.1, but it does not do what I expected. If I set an url in the url parameter of the rewrite tag, I wanted the system to simply show a different address in the address bar, but now the system redirect to the address I set in the url parameter.

    Probably I didn’t get exactly how pretty faces is working.

    Could you please explain if I can do what I need and how (provided that there are no bugs)?

    Thanks in advance,

    Giorgio

    PS

    I’m using some apache-commons jars that are more recent than those listed in the site. Could it be a problem?

    #20721

    Hey Giorgio,

    I think rewrite rules are the wrong approach in your situation.

    1) at present my server responds showing the IP address, so I’d like to show the internet address (that one that the user inserted).

    What do you mean by “responds showing the IP address”? Do you mean that you cannot enter the domain name to access the application? In this case it is a configuration issue. If your domain is set up with the IP address of your server, it should work as you expect it. If not, it is either a DNS or an application server issue.

    2) The user would like to see always the same address (i.e. http://www.myDomain.net) without the context part.

    You will have to do two things to achieve this:

    1. You must configure your container to deploy the application to the root context-path (/). In this case the application will be accessible with http://www.myDomain.net instead of http://www.myDomain.net/my-context-path.

    2. If your uses do not want the address in the browser bar to change regardless on which page they are, you may take a look at the following thread:

    http://ocpsoft.com/support/topic/constant-url-in-jsf-application

    I hope this helps :-)

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

You must be logged in to reply to this topic.

Comments are closed.