PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 22, 2022

[FIXED] Codeigniter Default Controller 403 Directory access is forbidden

 February 22, 2022     .htaccess, codeigniter, php     No comments   

Issue

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:\\localhost\mastertransaksi\

show error

Directory Access is Forbidden

but if

http:\\localhost\mastertransaksi\Homepenta

its work

anyone can explation how to fix this? Thanks


Solution

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.



Answered By - MrWhite
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing