2
votes

I use the following code in htaccess file located in /projects/testsite

AddType x-mapp-php5 .php
RewriteEngine On
RewriteBase /
Options -MultiViews 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . projects/testsite/index.php [L,QSA]

#ErrorDocument 404 /404.php

when i am in http://www.mydomain.com/projects/testsite/admin/articles/1/edit and i press Save which redirects the request to http://www.mydomain.com/projects/testsite/admin/articles/1/save

all post data are lost.

What i get if i try to debug is

POST: Array print_r: Array ( ) GET: Array print_r: Array ( )

What should i do to my .htaccess file to keep redirecting all requests to index.php but preserving all post data?

Thank you in advance!

P.S. my site works normally if i set it in a Windows Server with web.config rewrite rules.

UPDATE #1

From Firefox Live HTTP headers i see a significant issue: a 301 Moved Permanently header is captured only in Apache (this is not happening in IIS)

HTTP/1.1 301 Moved Permanently Date: Sun, 06 Apr 2014 13:48:06 GMT Server: Apache Location: http://mydomain.gr/projects/testsite/admin/articles/6/save Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 270 Keep-Alive: timeout=3, max=100 Connection: Keep-Alive

Content-Type: text/html; charset=iso-8859-1

UPDATE #2

It seems that there is some relation with this issue:

How to preserve POST data via ajax request after a .htaccess redirect?

where the asker finds out that someone was forcing a 301 redirect rule for every request on top of the .htaccess file.

Is it the hosting provider to blame?

1
file_get_contents('php://input');vp_arth

1 Answers

1
votes

This was quite baffling, hope i saved someone from the same headache:

The problem was located in Parallels Panel>Websites & Domains>mydomain.gr> Hosting Settings

Locate the select field:

Preferred domain, it was set to domain.tld but all my requests where to www.domain.tld so a 301 redirection (you lose all post data) was forced by parallels and not by my applications files.

Note that the label in Parallels warns that:

Regardless of the domain's URL that visitors specify in a browser (with the www prefix or without it), a page with the preferred domain's URL opens. The HTTP 301 code is used for such a redirection. The 'None' value means that no redirection is performed.

So my solution was to change Preferred domain to None.