Welcome Guest, Not a member yet? Register   Sign In
Ho to protect the project files or folder in codeigniter ?
#1

[eluser]ludo31[/eluser]
Hello ;
I begin and I suppose that I finish my project , so I would like to protect it in order someone can't change or can't access to it . How to do that .
I hear : .htaccess et .htpasswd but I don't know how to do and how it works ??

I find in CI project for example :


my folder's name of my project : is

Monsite
and inside : there are :
- index.php
- system
- js
- pictures
- css
- application

and inside application there are a lot of folder : and .htaccess file and index.html

so can you tell me please what to do ??
I d like to protect my project as possible !!

thanks
#2

[eluser]Stefan Hueg[/eluser]
I read through your post two times but could not understand what you want. Could you explain it a bit further?
#3

[eluser]InsiteFX[/eluser]
If you really want to protect them then move the ssystem and application folders outside of your root!

Edit index.php and set the correct paths to your system and application folders.
#4

[eluser]Aken[/eluser]
.htaccess files inside the application and system folders already prevent HTTP requests to those folders. But if you want better protection, do what InsiteFX said.
#5

[eluser]ludo31[/eluser]
thanks but please can you explain more because I begin with that , if I understand I put system and application outside the principal project Monsite .
after I edit index.php at the same directory than 2 folders (system and application ) and after we must set the correct paths to system and application folder / How to do that ????
#6

[eluser]ojcarga[/eluser]
What @InsiteFX & @Aken recommend you is to move the "application" and "system" folders one level top of your server's root. Example:

-- public_html
|- system
|- application
|- index.php
|- css
|- js

You have this structure right now, but you sould move the "application" and "system" folders

-- system
-- application
-- public_html
|- index.php
|- css
|- js

and then change the variables (they are in the index.php file which is in the root)

Code:
$system_path = 'system';
$application_folder = 'application';

Also change
Code:
define('ENVIRONMENT', 'development');
//TO
define('ENVIRONMENT', 'production');

http://ellislab.com/forums/viewthread/125687/
#7

[eluser]ludo31[/eluser]
[quote author="ojcarga" date="1335803853"]What @InsiteFX & @Aken recommend you is to move the "application" and "system" folders one level top of your server's root. Example:

-- public_html
|- system
|- application
|- index.php
|- css
|- js

You have this structure right now, but you sould move the "application" and "system" folders

-- system
-- application
-- public_html
|- index.php
|- css
|- js

and then change the variables (they are in the index.php file which is in the root)

Code:
$system_path = 'system';
$application_folder = 'application';

Also change
Code:
define('ENVIRONMENT', 'development');
//TO
define('ENVIRONMENT', 'production');

http://ellislab.com/forums/viewthread/125687/
[/quote]

I follow what you recommand but I have message error :

Code:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php

I put application and sytem outside so I create anothe folder : Principalfolder

so : it seems like this :


Code:
-Principalfolder
|-application
|-system
|-Mywebsite
      |-css
      |-js
      |-image
      |-.htaccess
      |-index.php

in index.php I write:

Code:
define('ENVIRONMENT', 'production');
$system_path = 'system';
$application_folder = 'application';

and in .htaccess I keep this code :


Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /MonSite

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

that's it
#8

[eluser]InsiteFX[/eluser]
Code:
$system_path = '../system';
$application_folder = '../application';
#9

[eluser]CroNiX[/eluser]
That's an outdated htaccess. The application and system directories have their own htaccess preventing access, so those rules dealing with them are unnecessary and from an older version of CI.
#10

[eluser]ojcarga[/eluser]
[quote author="InsiteFX" date="1335812703"]
Code:
$system_path = '../system';
$application_folder = '../application';
[/quote]

Yes, as @InsiteFX said should works.

But, the idea about changing the path of those folders is to place them in a place where they become unreachable, that means you should place them out of the server root. That is why I mentioned public_html and they should be in the parent folder of that "server root" (the server root in most cases is public_html).




Theme © iAndrew 2016 - Forum software by © MyBB