Anderson Laverde
Anderson Laverde

Reputation: 395

I have a error with codeigniter in local host with xamp

I Have a project in codeigniter and I'm using xampp, i have a button but when I redirect to other view i got an error.

Access forbidden! You don't have permission to access the requested object.

It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.

Error 403 localhost Apache/2.4.39 (Win64) OpenSSL/1.1.1b PHP/7.3.4

My .htaccess

RewriteEngine On

DirectoryIndex index.php
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

My config

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


$config['index_page'] = '';

and my link that doesnt work

<a href="<?php echo base_url() ?>application/views/index.php" </a>

Upvotes: 0

Views: 1049

Answers (1)

TimBrownlaw
TimBrownlaw

Reputation: 5507

From your stated issue I am not sure just how much you know about using Codeigniter.

You cannot access anything under the application folder directly from the URL with the exception of controller/method links as a general rule.

As an example to have a link to display a page, your link might be

<a href="<?php echo base_url(); ?>">Home Page</a>

This is a link to your default controllers index method. So it's something like a "Home Page".

Lets say your default controller is called Home_controller as set in your application/config/routes.php

$route['default_controller'] = 'home_controller';

The view

Your "index.php" view, I'll rename it to home_view.php

Your application/controllers/Home_controller.php

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

class Home_controller extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->load->view('home_view'); // show view called index (bad name)
    }
}

Without going into some full blown tutorial, this is using CI in it's simplest form just to give a quick demonstration of how to access a view.

Upvotes: 1

Related Questions