[英]CodeIgniter base_url leads to page not found
I'm using CodeIgniter, and I'm new at it, as I'm in web development. 我正在使用CodeIgniter,并且对我来说是新手,因为我正在从事Web开发。 I'm having a problem with the base_url
from CI: it leads to 404 Page not found
. 我对CI中的base_url
有问题:导致404 Page not found
。
Here is the referrence for the page: 这是该页面的引荐来源:
<li><a href="<?=base_url('Usual/novo_usual')?>">Cadastrar</a></li>
The controller's function: 控制器功能:
function novo_usual(){
$this->load->view('html-header');
$this->load->view('html-footer');
$this->load->view('cadastro_usual');
}
My controller's name file starts in capital, like Usual.php, and it extends CI_Controller
. 我的控制器的名称文件以大写字母开头,例如Usual.php,并扩展了CI_Controller
。
My altoloado.php: 我的altoloado.php:
$autoload['helper'] = array('url','html','form','funcoes');
My routes.php: 我的routes.php:
$route['default_controller'] = 'Home';
Finally the .htaccess file 最后.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
See \\application\\config\\config.php 参见\\ application \\ config \\ config.php
$config['base_url'] = ''; $ config ['base_url'] ='';
write to this your site url. 写入您的网站网址。
for example 例如
$config['base_url'] = ' http://test.com/ '; $ config ['base_url'] =' http://test.com/ ';
and now if you use base_url('Usual/novo_usual') this is equal http://test.com/Usual/novo_usual 现在,如果您使用base_url('Usual / novo_usual'),则等于http://test.com/Usual/novo_usual
If you don't set site url then first of set its 如果您未设置网站网址,则首先设置其网址
//Site URL Path : application\config\config.php
$config['base_url'] = 'http://localhost/site_name';
Then add this : 然后添加:
<?php
echo site_url('Usual/novo_usual');
//OR
echo base_url('Usual/novo_usual'); ?>
At first you need to set your folder path in 首先,您需要在以下位置设置文件夹路径
\\application\\config\\config.php \\程序\\设置\\ config.php文件
$config['base_url'] = '';
for example 例如
$config['base_url'] = 'http://localhost/folder/';
I've managed to solve it. 我设法解决了。 Turns out that my project's name starts with 'G', and in my url I was calling it with 'g'. 原来,我的项目名称以“ G”开头,在我的网址中我以“ g”命名。 Thanks guys. 多谢你们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.