Error in the end bar with mod_rewrite and mod_jk

3

I have the following structure on my server.

  • Apache HTTPD (port 80)
  • Tomcat (port 8080)

I used mod_jk to make the connection between apache and tomcat and this is working perfectly.

I created a subdomain to point to an application that is in tomcat. And I made the following VirtualHost configuration.

<VirtualHost *:80>
    ServerName www.cardapio.dreamt.com.br
    ServerAlias cardapio.dreamt.com.br
    JkMount /cardapio/* worker1
    RewriteEngine On
    RewriteRule ^/(.*) /cardapio/$1 [L,PT]
</VirtualHost>

However, I came across two problems:

  • Accessing cardapro.dreamt.com.br/dreamtech / (with the toolbar at the end), the application runs without any problems. And by accessing cardapio.dreamt.com.br/dreamtech (without the end bar) I am redirected to an invalid cardapio.dreamt.com.br/cardapio/dreamtech/ .
  • When accessing cardapio.dreamt.com.br/ my application does not work because it is trying to get the JS and CSS from cardapio.dreamt.com.br/ cardapio /xxx.js (for example). And I can not change because these imports are done automatically by JSF.
  • How to solve these problems?

        
    asked by anonymous 29.01.2014 / 19:28

    1 answer

    1

    The following rewrite rule appends a slash to the end specifically in the case of accessing the path /dreamtech :

    RewriteRule ^(dreamtech)$ $1/ [R]
    

    Try to put it like this:

    <VirtualHost *:80>
        ServerName www.cardapio.dreamt.com.br
        ServerAlias cardapio.dreamt.com.br
        JkMount /cardapio/* worker1
        RewriteEngine On
        RewriteRule ^(dreamtech)$ $1/ [R]
        RewriteRule ^/(.*) /cardapio/$1 [L,PT]
    </VirtualHost>
    

    Apache's own guide gives some tips on this issue of the bar and recommends this type of approach. See here .

    Previously, I had made an attempt using the generic rewrite condition checking to see if the URL was about a file, but that would not work anyway, since you're connecting to a Tomcat.

    You can do some tests of the rewrite module here or here .

        
    29.01.2014 / 19:47