Codeigniter 默认控制器 403 目录访问被禁止
Codeigniter Default Controller 403 Directory access is forbidden
我在 Mac OS Catalina 上使用 php 5.6.40 和 codeigniter 3.1.9
我的路线:
$route['default_controller'] = "Homepenta";
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
RewriteRule ^([^\.]+)$ .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
在浏览器上
http:\localhost\mastertransaksi\
显示错误
Directory Access is Forbidden
但是如果
http:\localhost\mastertransaksi\Homepenta
它的工作
任何人都可以解释如何解决这个问题?谢谢
您的 DirectoryIndex
似乎未设置或设置不正确(默认仅 index.html
)。将以下内容添加到 .htaccess
文件的顶部:
DirectoryIndex index.php
您的 mod_rewrite 指令没有将 /mastertransaksi/
重写为 /mastertransaksi/index.php
,因为这是一个物理目录,您的规则不包括目录。
403 结果是因为目录索引被禁用并且没有找到 DirectoryIndex
文档。
旁白: 您有多个不必要的 RewriteEngine
指令,应将其删除。还有...
<IfModule mod_rewrite.c>
RewriteEngine on
Options All -Indexes
</IfModule>
删除 <IfModule>
包装器和 RewriteEngine On
指令。只需保留 Options
指令即可。
我在 Mac OS Catalina 上使用 php 5.6.40 和 codeigniter 3.1.9 我的路线:
$route['default_controller'] = "Homepenta";
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
RewriteRule ^([^\.]+)$ .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
在浏览器上
http:\localhost\mastertransaksi\
显示错误
Directory Access is Forbidden
但是如果
http:\localhost\mastertransaksi\Homepenta
它的工作
任何人都可以解释如何解决这个问题?谢谢
您的 DirectoryIndex
似乎未设置或设置不正确(默认仅 index.html
)。将以下内容添加到 .htaccess
文件的顶部:
DirectoryIndex index.php
您的 mod_rewrite 指令没有将 /mastertransaksi/
重写为 /mastertransaksi/index.php
,因为这是一个物理目录,您的规则不包括目录。
403 结果是因为目录索引被禁用并且没有找到 DirectoryIndex
文档。
旁白: 您有多个不必要的 RewriteEngine
指令,应将其删除。还有...
<IfModule mod_rewrite.c> RewriteEngine on Options All -Indexes </IfModule>
删除 <IfModule>
包装器和 RewriteEngine On
指令。只需保留 Options
指令即可。