Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post Data is not recieved on destination URL

I had a scenario in which a data on form in http://www.omsite.com to be posted on other website say http://www.hissite.com/myfolder

Now whenever the data was being posted, rather then getting posted or getting Status Code 200 I was getting 301 Status code for permanent redirect and hence data was not getting posted.

Checking the destination URL I changed it from http://www.hissite.com/myfolder to http://www.hissite.com/myfolder/, yes, I added only a slash after /myfolder and there I got the successful response.

i need some help in understanding how just adding a forward slash at the end of destination URL made my data to get posted successfully?

Note: Destination webpage was the subdomain of source webpage

like image 230
OM The Eternity Avatar asked Mar 09 '23 13:03

OM The Eternity


1 Answers

i need some help in understanding how just adding a forward slash at the end of destination URL made my data to get posted successfully?

That is happening because myfolder on the destination site is a real directory. There is module called mod_dir in Apache responsible for this behavior due to security reasons.

  1. Whenever a request comes for a real directory without a trailing slash then mod_dir redirects to same URI plus a trailing slash using 301 status code.
  2. Once 301 redirect happens POST data gets lost.
  3. When you used http://www.hissite.com/myfolder/ to POST data then mod_dir didn't come into picture since your URI already has a trailing slash hence no redirect and no loss of POST data.

This behavior can be changed using:

DirectorySlash Off

But it is considered a potential security risk as it might reveal directory content.

like image 140
anubhava Avatar answered Mar 19 '23 05:03

anubhava