Welcome Guest, Not a member yet? Register   Sign In
Form not posting data to controller...htaccess problem
#1

[eluser]Unknown[/eluser]
My .htaccess file did get the url to rewrite thus removing the ‘index.php’ part. Url and everythings works. Only problem is for forms, it goes to a controller method, but $_POST array is always empty.

I’ve changed config.php to default settings. Url has ‘index.php’ for now. The forms work. $_POST array has data in it again.

Am I doing something wrong in .htaccess file? Why is it the $_POST array is empty with that setting? .htaccess file is exactly as typed:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /rbs/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
#2

[eluser]leighmarble[/eluser]
I was just facing the same problem, and was tearing my hair out trying to figure it out. I went over the .htaccess file again and again, but nothing changed the problem...

By using the "Live HTTP Headers" extension for Firefox, I was able to identify the issue. There was a 301 redirect happening, to add "www" to the beginning of the URL. I did not have such a directive specified in the htaccess file, but I remembered that were was a setting about this in my service provider's control panel.

I'm hosting on Dreamhost, and in the domain management section of their control panel, there is a setting called "Do you want the www in your URL?" This had been set to "yes", which caused a 301 "permanent redirect"... which meant it was losing POST data. I believe there are workarounds for this with proxies, but the immediate solution was to set the "www" setting to "Leave it alone".

POST data now arrives safe and sound.

And the "Live HTTP Headers" extension stays in my browser, for the next time I have to hack through this kind of troubleshooting...

cheers,
Leigh
#3

[eluser]chenx[/eluser]
Hello everybody, I have the same problem here. My CI is the newest, 2.1.2.

So, in localhost, all my CI code works fine, and the $_POST data is submitted too.

But in my server, the $_POST data is empty whenever I want to submit the data. But if I access the page with "index.php", it worked!

The Server:
http://dev.microad.co.id/backend/login
(it didn't work)
http://dev.microad.co.id/index.php/backend/login
(it worked!)

This is my .htaccess

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(/index\.php|/assets|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)\.html$ /sites/benesse_staging/index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(/index\.php|/assets|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /sites/benesse_staging/index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /sites/benesse_staging/index.php
</IfModule>

I hope anyone can help me with this, I dont know what to do so my submitted data can run on my server instead localhost.




Theme © iAndrew 2016 - Forum software by © MyBB