Apache tomcat + apache httpd + mod_proxy + mod_rewrite + form data

Please help me. I tried to find a similar problem by reading old posts, but didn't find anything. I have a problem with the data to publish. I am using Apache tomcat + ajp + Apache Httpd 2.2 Here is part of my httpd.conf :

#Application has context url = konakart, and tomcat post 8789 for ajp
#I want to avoid typing port in my URL
ProxyPass / ajp://localhost:8789/konakart/

#pretty urls
#I don't want to type http://myshop.com/konakart
#I want http://myshop.com
#I want to put away /konakart/ from URL
RewriteEngine on
Options +FollowSymlinks
RewriteRule ^/konakart/(.*) /$1 [R=301,L] 
RewriteRule send-mail index.php?send-mail [NC,P]

Everyting is fine ... except that from the POST data is lost. It looks like this because of R = 301. But I can’t remove R = 301. If I do, nothing will work. I am using VDS so that I can do something ... please help me overcome this problem. :(

+1
source share
1 answer

mod_rewrite GWT ;) httpd.conf, . :

    #Tomcat through Apache httpd
    ProxyPass /konakart ajp://localhost:8789/konakart
    ProxyPass / ajp://localhost:8789/konakart/

    #pretty urls

    RewriteEngine on
    Options +FollowSymlinks
#do not do anything for POST actions and GWT stuff. It better not to touch it at all.
#mod_rewrite breaks interconnection of GWT RPC calls.
    RewriteCond  %{REQUEST_URI} !/(.*)EditCartSubmit\.do(.*)
    RewriteCond  %{REQUEST_URI} !/(.*)Submit\.do(.*)
    RewriteCond  %{REQUEST_URI} !/(.*)\.cache\.html
    RewriteCond  %{REQUEST_URI} !/(.*)\.nocache\.(.*)\.js
#Previously GWT servlet had mapping "/konakart"
#I've renamed it to "/KonakartGWTServlet"
    RewriteCond  %{REQUEST_URI} !/KonakartGWTServlet
    RewriteRule ^/konakart/(.*) /$1 [R=301,L] 
0

Source: https://habr.com/ru/post/1735038/


All Articles