我使用codeigniter开发了一个Web应用程序。在我的localhost中它可以正常工作。但是当我将它托管到实时服务器(共享服务器)时,它无法正常工作。 我在实时服务器上调用主URL时获取主页,但是通过控制器的任何URL都无法正常工作
调用网址“http://my_domain.in/pages/second_page”时收到以下错误
The requested URL /my_domain.in/my_domain.in/index.php/pages/second_page was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at my_domain.in Port 80
我在错误字符串URL上注意到我的域名正在重复,但在实际的URL上,它不是那样,而且还找到了index.php。所以我已经多次改变了.htaccess代码来解决这个问题。那时错误消息上的URL正在改变,但没有成功的结果。
最后我把它托管在我朋友的服务器上。那个时候它像我的localhost一样正常工作。你能告诉我服务器的问题吗?在该服务器上使用codeigniter时是否有任何启用或禁用功能? codeigniter框架从未在此服务器中使用。
答案 0 :(得分:0)
要获得更好的答案,您需要提供托管服务提供商名称。您可以尝试使用以下.htaccess。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
答案 1 :(得分:0)
看起来你隐藏了index.php,但错误提到了它 ==> /my_domain.in/my_domain.in/index.php/pages/second_page未找到
您是否也在配置页面中删除了它? \配置\ config.php中
确保$ config [' index_page'] ='&#39 ;; 并使用这些行添加.htaccess文件
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
我在Windows和Linux机器上测试时遇到了这个问题,并调整了config.php。
if (file_exists(FCPATH.'.htaccess')) {
$config['index_page'] = '';
}
else {
$config['index_page'] = 'index.php';
}
第一个没有.htacsess文件的teste 如果一切顺利,请将.htaccess文件放在根目录中,然后重试。
如果仍然出现此错误,请查看已编码的链接,并查看其中是否提到了index.php。