skip to Main Content

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


  1. 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.”

    Login or Signup to reply.
  2. There is maybe better approach for what you want. Move application and system directories outside public_html and after that just set new paths to those directories in public_html/index.php file that should be:

    $system_path = '../system'; // line 93
    

    and

    $application_folder = '../application'; // line 110
    
    Login or Signup to reply.
  3. In the directories that are off limits to visit from a browser:
    place a .htaccess file containing:

    order deny,allow
    deny from all
    

    But if possible, move those directories outside the document root

    Addendum
    I forgot: for Apache 2.4 the syntax is

    Require all denied
    

    instead of the 2 lines for older Apache versions

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search