Welcome Guest, Not a member yet? Register   Sign In
Removing index.php from public folder to root folder
#1

Hello everyone,

I was having problems removing "public" from my url , I saw a suggestion online to move the index.php from the public folder to the root folder and edit the following code from:



Code:
$pathsPath = FCPATH . '..app/Config/Paths.php';



to


Code:
$pathsPath = FCPATH . 'app/Config/Paths.php';


Want to know if there are any security consequences to this?
Reply
#2

(This post was last modified: 03-01-2020, 11:20 AM by dave friend.)

No, do not do that.

FCPATH should be the webroot folder.

Just to be clear, "webroot" is the folder that the domain name itself points to. It should the only folder accessible using HTTP.

The webroot folder is set up by the webserver configuration. For Apache, that means either a "sites_available" config that most often sets up a "virtual host".

With regards to CodeIgniter's file structure, only one folder should be publicly accessible and that is the "public" folder. Said another way, "public" should be the webroot folder. However, the "public" folder does not have to be named "public". If you cannot change the server config then you can, and should, rename the public folder to match the server's config. CodeIgniter does not care what the name of the folder is. It only cares that index.php is found there.

If you can move index.php to the root folder and access it using a browser you're setup is wrong and the site is very insecure.

When the server is set up correctly the $baseURL will not need to include a path. It will only need to contain the domain. It should look something like this.

PHP Code:
public $baseURL 'http://example.com/'

And not like this.

PHP Code:
public $baseURL =  'http://example.com/public/'

Then you won't have to deal with removing 'public'.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB