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

Deadly 提交于 2019-12-11 05:53:55

问题


please help me. I did try to find similar problem here reading old posts, but I didn't find anything. I have a problem with post data. I'm using Apache tomcat + ajp + Apache Httpd 2.2 Here is a 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 ok... except that from POST data is lost. Seems like it's because of R=301. But I can't put away R=301. If I do so nothing works. I'm using VDS so I can do anything... please help me to overcome this problem .:(


回答1:


It was combined problem of mod_rewrite and GWT and my curl hands ;) Here is valid httpd.conf code, see comments in code:

    #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's 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] 


来源:https://stackoverflow.com/questions/12258698/apache-tomcat-apache-httpd-mod-proxy-mod-rewrite-form-post-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!