1

Hello all i am new to MVC and after attempting a mod_rewrite i am having trouble with 403 when i attempt to load site/about. I have my project in the main root directory of my web server htdocs, i have struggled to understand many of the tutorials online. The error is;

Forbidden

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while 
trying to use an ErrorDocument to handle the request.

site - controller

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

class Site extends CI_Controller {

public function index()
{
    $data['title']= "Welcome Learn Guitar Online";
    //$this->load->view('home',$data);
    //$this->getValues();
    $this->load->view("about",$data);

}
}

about.php

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $title; ?></title>

</head>
<body>

<div id="container">
<h1>Welcome to about</h1>
<div id="body">
    <p>hello</p>
</div>

<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>

</body>
</html>

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

config file variables

$config['base_url'] = 'localhost/index.php';
$config['index_page'] = '';

2 Answers 2

1

You are attempt to load site/about. but as I seen your code there is no function named as about. You just need to call your controller i.e. http://localhost/FOLDER_NAME/site and default it will call index function and load the about.php view.

Your config.php should like this

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

If you have put your ht.access inside your project folder than there is no need to define base_url() also.

Sign up to request clarification or add additional context in comments.

Comments

0

can you try making the .htaccess to this

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /FOLDER_NAME/
    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.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

in Config

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

Replace FOLDER_NAME with your folder name. Now you should be able to access your url without index.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.