简体   繁体   English

为什么当我单击带有基础 url 的 A href 时,使用 codeigniter 找不到页面 404

[英]Why When I Click A href with base url the Page is 404 Not Found using codeigniter

Hello Everyone I want To Ask Why When Change Page using href i got 404 Not Found?大家好,我想问为什么当使用href更改页面时我得到404 Not Found?

this is the path on my codeigniter这是我的 codeigniter 上的路径

this config my base url这个配置我的基础 url

$config['base_url'] = 'http://localhost/Fenix/';

this is config for index page这是索引页面的配置

$config['index_page'] = '';

and i already give.httacess on root我已经在 root 上给了.httacess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And href i want to click我想点击href

<li class="nav-item"><a class="nav-link js-scroll-trigger" href="<?php echo base_url('controllers/Login_Controller')?>">Login</a></li>

And The Controller和 Controller

 <?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login_Controller extends CI_Controller
{
     public function index()
    {
        $this->load->view('login');
    }
}

Can Anyone Help Me About This I'm Still New About Codeigniter任何人都可以帮我解决这个问题我还是关于 Codeigniter 的新手

maybe you should use this也许你应该使用这个

<li class="nav-item"><a class="nav-link js-scroll-trigger" href="<?php echo site_url('Login_Controller')?>">Login</a></li>

in codeigniter you have not to call a folder just controller and the function and when you call Login_Controller codeigniter will automatically read function index() in codeigniter you have not to call a folder just controller and the function and when you call Login_Controller codeigniter will automatically read function index()

hope it help!希望有帮助!

Replace this替换这个

before =>之前 =>

href="<?php echo base_url('controllers/Login_Controller')?>"

after => => 之后

href="<?=site_url('login_Controller')?>"

You can to use $this-load->helper('url') , if necessary如有必要,您可以使用$this-load->helper('url')

You can see the full document here您可以在此处查看完整文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM