I have nginx 1.0.2 installed on Ubuntu 11 with php 5.3.5 running with FPM/FastCGI.
On a codeigniter applilcation of mine i get the following problem.
I have a simple login form with a username and password field. When I submit the form the $_POST array is empty. So is $this->input->post('username') and $this->input->post('password').
The application works fine on apache. I tried creating a simple test form on a simple php file and $_POST data worked perfectly. I can provide configuration files if needed. Any ideas ?
Update:
It finally worked. There were some redirects in my vhost config which were causing loss of post data. The working vhost config can be found here: http://codeigniter.com/forums/viewthread/90231/#455528
I think I know the issue now. The fact that it's returning 404 and processing your script tells me that the error_page is what's doing the 'rewrite' to get the request to /index.php. An error_page to a non-named location will transform the request into a GET, so the error_page 404 /index.php is doing an internal redirect to /index.php, but it's stripping the request body in the process (and the lack of an = means the status code isn't overridden by the error_page target). I'm not sure why all those ifs aren't performing the redirect (if processing in nginx is really weird, so it's a good idea to avoid them), but I think if you use a named location for your error page, that will preserve the request body and fill in $_POST. Try replacing your current error_page directive with:
location #redir {
rewrite ^ /index.php;
}
error_page 404 = #redir;
check these:
<form method="post">
you using the post method?
try running the profiler:
$this->output->enable_profiler(TRUE);
seeing any POST output there?
I was using my own PHP framework with similar URI rewrites as CI and on Nginx server had similar issues, cause my forms had actions like: action="admin/login/post" and I had to change them to end with .php action="admin/login/post.php" so they could work, but this requires you to change the URI rewrite of your CI class to replace that .php from the uri string.
I had a similar problem and i tried everything mentioned here. It was very simple when i figured it, I had not named my input variables in the form. I had missed the name parameter.
<input type="name" placeholder="Name" name="name">
Related
If I have a URL like this:
http://localhost/Cool Website/
I will get this error:
404 Page Not Found: The page you requested was not found: Cool Website/index
However, when I use underscores like http://localhost/Cool_Website/
CodeIgniter loads as intended. This issue is now manifesting itself after pasting the CodeIgniter folder as a subfolder into our main project which has spaces in its name that I cannot change. (I can and have changed the CodeIgniter project's name to use underscores)
Is there a workaround for this?
Update: solved my issue by changing system files. I am running php 5.3.13.
I went to the URI core file and put this in the _parse_request_uri:
$uri = str_replace('%20', ' ', $uri);
At line 206, after $uri = isset($uri['path']) ? $uri['path'] : '';
This seems to have fixed it. I reverted the change to QUERY_STRING in my config file because QUERY_STRING was empty. This may be a CodeIgniter 3.0 bug. My guess is the 20% wasn't being "considered valid" by the uri code, so changing it back to a real space made it work again as it truly is the proper URL.
I have a site built in drupal 7 where I use an adding node form which uses ajax for form submission (I use the modal module or the ajax_entity module). In both case when I submit the code the node is not create and I receive the following error in a popup:
"An AJAX HTTP request terminated abnormally. Debugging information follows. Path: http://demo/q=modal/node/add/TestType/ajax/0" Status text:n/a ResponseText:Skip to main content"
I dont if this is important but the node form is divided in vertical tabs and it is opening in modal window. Also it includes textboxes,textareas and file upload field, but in this case still I havent used the file upload fields.
Thanks in advance
Most of the type Drupal Ajax Http error occurs when Drupal cant find Base URL.
So to resolve this issue follow below steps
Set $base_url variable in settings.php
If you have written some custom module, then make sure that whenever you to execute Ajax, check base_url variable have proper value. You can verify base_url value by printing this variable.
I recently had a similar issue and found that someone adjusted the X-Frame-Options in Apache. If you look in the browser's console log, I had this error displaying:
Refused to display 'https://www.example.com/file/ajax/field_heading_background_image/und/0/form-kfxURDN5ZPpN5pjFWajkPCDpMKJrrJthX9WVcY2K8' in a frame because it set 'X-Frame-Options' to 'DENY'.
Adding this to your .htaccess should fix it, but you can also adjust the server configuration:
Header always unset X-Frame-Options
Header set X-Frame-Options SAMEORIGIN
I have strange problem with CodeIgniter and routing system and can't find solution for it, so: I have several routes such as
'forum/(:num)'
=> 'forum/category/$1',
'forum/(:num)/(page:any)'
=> 'forum/category/$1/$2',
and them works, but return 404 code in header.
I mean I don't get 404 page, correct HTML returns and page's content displays correctly for my forum's categories. But I'm getting 404 in header (Network tab in Firebug), so I can't work with POST data correctly.
If I request /forum/ - 200 Ok returns, but when I trying to get routed page, I get right page, but with 404 Not Found.
I'm using PHP5.4+Apache2 on Linux host, if it will help You to give me solution.
I've found solution! Maybe it will save someone's time.
Problem wasn't in CodeIgniter, I've found solution in activation mod_rewrite. Yes, that worked, but wan't activated in Apache.
Just try to do
sudo a2enmod rewrite
and restart apache service after
sudo service apache restart
And all routed pages will return 200 Ok
None of these worked, but I did this instead:
At the end of my controller I put this:
$this->output->set_status_header('200');
and actually though that worked, the problem turned out to be a controller name that conflicted with a real directory name...
I'm having a problem with CI 2.1.3 redirect function.
Everytime I call redirect, it shows a white-blank page. In fact, it works well on my localhost, the problem just occurs on my real server (with CentOS 5 installed).
This is how I call the redirects :
redirect('frontend/article/index');
or
redirect(base_url('articles.html'));
I did add a route in config/routes.php
$route['articles.html'] = 'frontend/article/index';
with : frontend is module, article is controller, and index is action (I'm using wiredesignz's HMVC module extension)
How could I fix it? And what is the problem here?
Thanks in advance!
UPDATE
I replaced CI redirect function by calling :
header("Location: http://example.com");
but it didn't work too.
So I created a file named info.php and uploaded it to my server. Here's the content:
<?php
phpinfo();
?>
When I type in the address bar : http://example.com/info.php, it shows like in the image.
Why was there a ">" character? Was it the problem causing redirect not working?
Firstly, make sure error reporting is enabled, or try placing the following at the top of your index.php.
error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', TRUE);
If this doesn't point you in the right direction make sure you don't have any output echo, print_r, print, dump, etc before your call to redirect() method.
Another common cause or problems when moving to a new environment is white space. Check that your files don't have any whitespace at the bottom of them.
if you are defining .html in the config.php as the file ext. you do not need to postfix the route with it.
$route['articles'] //instead of $route['articles.html']
Also you need to remove the base_url() from the redirect cos that is not needed.
redirect('articles'); //should sort it
Hope this sorts ur problems.
EDIT
If this is still not working after attempting these changes, it will most likely be a problem in the controllers. If this is the case you may need to turn on error reporting in your index.php file to find out exactly where the problem is occurring.
Ok, this is not a rewrite error because I did not touch the conf file.
I used http://www.farinspace.com/install-and-configure-nginx-server/ to make the web server.
The thing is CodeIgniter & Kohana does work on http://url.com/sub/ and http://url.com/sub/index.php
But, it does not work with http://url.com/sub/index.php/welcome or any controller (am I calling that right?), I get a 404 Not found.
am I calling that right?
Obviously not. 404 error in kohana / codeigniter means that no matching controller / action could be found. Additionally 404 error by the server means that the overall resource was not found.
Nginx requires a different server configuration than apache. RewriteRule is only one example.