I’m using Codeigniter with Hostgator shared hosting.
How to set sub directories/folders in public_html 403 forbidden? but the files in this folders is accessable.
example:
/public_html/this_forlder_forbidden/this-file-not-forbidden.ext
example 1
/public_html/js/jquery.js
/public_html/css/style.css
below is my .htaccess file codes in /public_html/ directory.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
SetEnvIf Origin "http(s)?://(.+.)?mydomain.com(:d{1,5})?$" CORS=$0
Header set Access-Control-Allow-Origin "%{CORS}e" env=CORS
Header merge Vary "Origin"
3
Answers
Go to Codeigniter/application folder
copy index.html
and paste it in /public_html
when someone tries to open /public_html then index.html trigger automatically.
index.html show “Directory access is forbidden.”
There is maybe better approach for what you want. Move
application
andsystem
directories outsidepublic_html
and after that just set new paths to those directories inpublic_html/index.php
file that should be:and
In the directories that are off limits to visit from a browser:
place a .htaccess file containing:
But if possible, move those directories outside the document root
Addendum
I forgot: for Apache 2.4 the syntax is
instead of the 2 lines for older Apache versions