Javascript $.post到Codeigniter控制器/方法404页未找到
我已经开发了一个Codeigniter原型应用程序,并在开发阶段与Godaddy.com一起托管,用于测试目的,没有问题。该应用程序使用javascript、jquery、HTML5、CSS和PHP(Codeigniter框架)的组合。本周,我将应用程序转移到客户机服务器,遇到了许多配置问题,但最终遇到了麻烦 客户端使用PHP5在新的Linux/Apache2服务器上重新安装。mod_rewrite已启用,allowoverride设置为all。Apache2设置(每个客户端)为 我的.htaccess脚本(自本期发行以来,我尝试了许多不同的.htaccess版本) 我的javascript代码,用于将序列化表单数据发布到PHP页面Javascript $.post到Codeigniter控制器/方法404页未找到,javascript,php,apache,.htaccess,codeigniter,Javascript,Php,Apache,.htaccess,Codeigniter,我已经开发了一个Codeigniter原型应用程序,并在开发阶段与Godaddy.com一起托管,用于测试目的,没有问题。该应用程序使用javascript、jquery、HTML5、CSS和PHP(Codeigniter框架)的组合。本周,我将应用程序转移到客户机服务器,遇到了许多配置问题,但最终遇到了麻烦 客户端使用PHP5在新的Linux/Apache2服务器上重新安装。mod_rewrite已启用,allowoverride设置为all。Apache2设置(每个客户端)为 我的.hta
$.post('login_ctrl/authenticateuserlogon', $formData, function($responseData)
{
$userAuthentication=$responseData.userAuthentication;
if ($userAuthentication=='success')
{
window.location.href = "student_portal_ctrl";
}
else
{
$('#loginErrDiv').text('Username or Password is incorrect - Please try again.');
return;
}
});
我的codeigniter文件结构是
-root /
/CI
/application
/system
/index.php
/license.txt
/.htaccess
当我发布到此控制器/方法时,浏览器输出
----编辑---
抱歉,忘记包含我的config.php设置,它们在这里
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; //I have tested the app using all of codeigniters
//default URI Protocols
----编辑#2---
这是接收404错误的控制器上的方法
//AUTHENTICATE USER LOGIN FUNCTION
public function authenticateuserlogon()
{
//SETTING $FORMDATA TO SERIALIZED POST DATA
$formData = $this->input->post();
//Sets the Method for the login_mdl
$modelMethod=$formData['modelMethod'];
//LOADING USER AUTHENTICATION LOGIN MODEL
$this->load->model('login_mdl');
//SENDING FORMDATA TO MODEL AND RETURING DATA TO $RESPONSEDATA
$responseData = array();
$responseData = $this->login_mdl->$modelMethod($formData);
//OUTPUTTING JSON RESPONSE DATA BACK TO JAVASCRIPT
$this->output->set_output(json_encode($responseData));
}
使用此
.htaccess
,它经过我的测试,工作正常
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
打开
http://yourip/CI
?@Deepak当我打开。。。浏览器正确加载my index.php,它加载默认登录控制器,它加载我的登录视图。当我点击登录表单上的submit按钮(调用上面的javascript post代码)时,就是当我收到404 not found错误时,您是否尝试在url中添加index.php。只是为了验证tat是否有效。@Deepak也正确加载了站点。当您执行65.44.222.164/CI/index.php/login\u ctrl/authenticateuserlogon时,我已经更新了代码和.htaccess。现在,当我提交表单时,我收到的是“NetworkError:500内部服务器错误-”而不是404 Not Found erroryes,这意味着您的代码中有错误。请检查您的apache错误日志扫描您发布的authenticateuserlogon
方法?首先,感谢您的耐心,因为我快疯了。:)以下是我的apache错误日志,其中500个错误[debug]mod_deflate.c(615):[client 98.154.88.186]Zlib:Compressed 1166-527:URL/CI/index.php[debug]mod_deflate.c(615):[client 98.154.88.186]Zlib:Compressed 1166-527:URL/CI/index.php[debug]mod_deflate.c(615):[client 98.154.88.186]Zlib:Compressed 92651 to 32770:URL/CI/js/jquery-1.9.1.min.js,referer:[debug]mod_deflate.c(615):[client 98.154.88.186]Zlib:Compressed 3089 to 1061:URL/CI/css/login.css,referer:[debug]mod_deflate.c(615):[client 98.154.88.186]Zlib:Compressed 2638 to 1111:URL/CI/js/login/login.js,referer:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];