Skip to content
Advertisement

Codeigniter Default Controller 403 Directory access is forbidden

Im using php 5.6.40 and codeigniter 3.1.9 on Mac OS Catalina myroutes :

$route['default_controller'] = "Homepenta";

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^([^.]+)$ $1.php [NC,L]
RewriteEngine On


<Files .htaccess>
order allow,deny
deny from all
</Files>

<IfModule mod_rewrite.c>
RewriteEngine on
Options All -Indexes
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# This domain inherits the “PHP” package.
# php -- END cPanel-generated handler, do not edit

on browser

http:\localhostmastertransaksi

show error

Directory Access is Forbidden

but if

http:\localhostmastertransaksiHomepenta

its work

anyone can explation how to fix this? Thanks

Advertisement

Answer

It looks like your DirectoryIndex is not set, or not set correctly (it defaults to index.html only). Add the following to the top of your .htaccess file:

DirectoryIndex index.php

Your mod_rewrite directives are not rewriting /mastertransaksi/ to /mastertransaksi/index.php because this is a physical directory and your rule excludes directories.

The 403 results because directory indexes are disabled and no DirectoryIndex document is found.

Aside: You have multiple RewriteEngine directives which are unnecessary and should be removed. Also…

<IfModule mod_rewrite.c>
RewriteEngine on
Options All -Indexes
</IfModule>

Remove the <IfModule> wrapper and RewriteEngine On directive. Just keep the Options directive.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement