I'm building a CMS over an MVC framework I'm also building, but I'm stuck here. The full code can be found at this link to github.
Ok, the problem I'm having is with this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_METHOD} !POST [NC]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
When I run the code on "auth/login" via this ajax request:
$.ajax({
type: "POST",
url: "auth/login",
dataType: "json",
data: { username: username, password: password, token: token_value }
})
When I run:
$username = $_POST['username'];
$password = $_POST['password'];
$token = $_POST['token'];
$postdata = array('username' => $username, 'password' => $password, 'token' => $token);
print_r($post_data);
print_r($_SERVER);
I get:
Array (
[username] =>
[password] =>
[token] =>
)
Array(
[REDIRECT_REQUEST_METHOD] => POST
[REDIRECT_STATUS] => 404
[HTTP_HOST] => [omitted]
[HTTP_CONNECTION] => keep-alive
[CONTENT_LENGTH] => 71
[HTTP_ACCEPT] => application/json, text/javascript, */*; q=0.01
[HTTP_ORIGIN] => [omitted]
[HTTP_X_REQUESTED_WITH] => XMLHttpRequest
[HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
[CONTENT_TYPE] => application/x-www-form-urlencoded; charset=UTF-8
[HTTP_REFERER] => [omitted]/auth
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.8,fr;q=0.6
[PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[SERVER_SIGNATURE] => <address>Apache/2.4.7 (Ubuntu) Server at [omitted] Port 80</address>
[SERVER_SOFTWARE] => Apache/2.4.7 (Ubuntu)
[SERVER_NAME] => [omitted]
[SERVER_ADDR] => [omitted]
[SERVER_PORT] => 80
[REMOTE_ADDR] => [omitted]
[DOCUMENT_ROOT] => [omitted]
[REQUEST_SCHEME] => http
[CONTEXT_PREFIX] =>
[CONTEXT_DOCUMENT_ROOT] => [omitted]
[SERVER_ADMIN] => webmaster@localhost
[SCRIPT_FILENAME] => [omitted]/public_html/index.php
[REMOTE_PORT] => 60135
[REDIRECT_URL] => /auth/login
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /auth/login
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
[REQUEST_TIME_FLOAT] => 1447625662.493
[REQUEST_TIME] => 1447625662
)
I know the above block of code works because I've tried it on a static "test.php" file and it outputs the username/password/method information submitted by this ajax request.
I really feel like the problem lies within my .htaccess file because when I force a 200 OK header it still considers it a 404 or something? I'm not sure but its scrubbing the $_POST. This issue isn't related to my php.ini or apache2.conf, since I've tested that out already and I'm able to receive post data, just not to the ErrorDocument 404 /index.php that I've been sending it to. This is what I've been using to prevent a 404 page when parsing the URL to send to the controller.
Any help would be much appreciated!