Ken CHAN
Ken CHAN

Reputation: 13

Codeigniter index.php in the subfolder

I am new to Codeigniter. I want to make safe to the model, controller and views. I have found that it is good to put the index.php in a folder of public like below.
--root
  --application
  --public
      --css
      --js
      --assets
      --index.php (the Codeigniter base index.php)
      --.htaccess
  --system
.htaccess
What should I do for the file that bold,so that when I enter the "example.com/controller/method" can see my page. I don't want "example.com/index.php/controller/method" I hope you got the questions.

[edit] I add more to explain.
I know how to hide index.php

example.com/public/controller/method => got the page
example.com/controller/method => can't got the page

I want the second one can show the page if I put the index.php into public folder!

Upvotes: 0

Views: 426

Answers (3)

Nere
Nere

Reputation: 4097

For me, if you want to make it safer... I advised you to rename

application folder and system folder

E.g:

application change to my_secret_application

and

system change to my_secret_system

And in your index.php

$system_path = 'my_secret_application';
$application_folder = 'my_secret_system';

Upvotes: 0

CiaranSynnott
CiaranSynnott

Reputation: 928

I'm not sure what you want to achieve;

if you want to remove index.php from the url so you have

example.com/controller/method instead of example.com/index.php/controller/method

You need to create a .htaccess file

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?r=$1 [L,QSA]

Upvotes: 0

DNReNTi
DNReNTi

Reputation: 521

In the index.php you should change the $system_path and the $application_folder variables, and thats should do it.

In your case:

$system_path = '../system';
$application_folder = '../application';

And of course your document root must to point to your public folder. Hope it helps.

Upvotes: 0

Related Questions