0

post parameters are not getting to the server after it goes through an internal redirect on apache. So www.mydomain.com would keep my post parameters, but mydomain.com doesn't. how do I fix this?

<VirtualHost *:80>
    ServerName mydomain.com
    Redirect permanent / http://www.mydomain.com/
</VirtualHost>
1
  • "it goes through an internal redirect" - just to clarify, the redirect shown above is an external redirect, not an internal redirect (aka internal rewrite).
    – MrWhite
    Feb 23, 2018 at 11:53

3 Answers 3

0

I don't think you want to redirect in this case. The forms that they are posting from should post directly to www.mydomain.com, not mydomain.com.

You can use a ServerAlias in the specification for the www.mydomain.com to include traffic addressed to mydomain.com. You may want to do limited redirects from pages on mydomain.com to www.mydomain.com.

2
  • the problem that I use redirect is for SEO purpose, if I don't use redirect, search engine thinks mydomain.com and www.mydomain.com are two different sites. ServerAlias doesn't have this SEO benefits, any thoughts?
    – user12145
    Jun 2, 2010 at 21:25
  • Use a robots.txt on mydomain.com than forbids all access. Any decently behaving crawler will then ignore the site. Exclude POST targets in the robots.txt for www.mydomain.com. You shouldn't be getting a post on an initial contact. This leads me to believe your forms think they should post to mydomain.com rather than www.mydomain.com. Check your site configuration. If you solve than then you can redirect from either configuration.
    – BillThor
    Jun 3, 2010 at 13:26
3

You must use the HTTP status code 307 in that case. See RFC 2616 (read 302, 303, 307). See wikipedia for a less “specificational” description.

See apache docs about Redirect for how to do this in this case.

3
  • I read through those http status code, but not sure how/which would help me.
    – user12145
    Jun 2, 2010 at 20:02
  • Oh I just said “the HTTP status code” – I forgot a 307 there :-) See the linked Wikipedia article: “In contrast to 303, the request method should not be changed when reissuing the original request. For instance, a POST request must be repeated using another POST request.”
    – Marian
    Jun 2, 2010 at 22:17
  • Nice - worked for me
    – jira
    Oct 9, 2012 at 10:06
0

Keeping the post parameters depends on the client to resubmit the POST data to the new location. I am pretty sure I read in the RFC at one point in time that the clients are not supposed to do resubmit POST data after a redirect has been received.

I will update when I find the reference.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .