6

I'm trying to install an application made with codeIgniter in a subfolder, so that I can access it using : http://www.domain.com/my_subfolder/ At the root, there's a Wordpress application. I edited the .htaccess of the Wordpress install to let the request go to the folder /my_subfolder/

It's working fine, the only problem I get is that CodeIgniter is unable to dynamically load the classes in the "libraries" directory. So everything in the CI application works fine until it tries to use an object declared in the "libraries" subfolder, then I get a : Unable to load the requested class: my_class

It doesn't seems that there's a parameter in the "config" folder to change that... any idea?

6
  • Tail your error logs and see whats happening here. As everything is relative it really shouldn't matter where your CI install is. Paste up your config and the error message you are receiving. Give us something to work with. :-) Commented Feb 4, 2010 at 9:03
  • @PhilSturgeon can anyone help me on this stackoverflow.com/questions/25447009/… Commented Aug 22, 2014 at 17:09
  • I am having the problem of 404. Can you show me your .htaccess? Commented Dec 23, 2017 at 13:53
  • @kamranbhatti585 It was 7 years ago... That .htaccess is long gone... Commented Dec 27, 2017 at 20:41
  • @mrmuggles Thanks though I solved it. :) Commented Dec 28, 2017 at 7:16

3 Answers 3

7

What you need is to edit your CodeIgniter config.php in System > application > config.

and then edit config.php and set the property:

$config['base_url'] = "http://www.domain.com/my_subfolder/"
Sign up to request clarification or add additional context in comments.

Comments

1

Well it seems that the config param base_url should be updated. Also, I used a library with the "MY_" prefix, and I should'nt since I was'nt extending any CI class.

Comments

1

This is 2021. In case anyone is having this same issue with CodeIgniter 4, this is how I solved it when I came across this issue.

Problem I installed CI in a subfolder in my public_html folder i.e example.com/api. When I visited www.example.com/api, I saw a 403 forbidden error.

Solution

  • Download and unzip CI on your local machine or use composer.

  • Rename public folder to the name of your subfolder. In my case, I named it api.

  • Create another folder and give it any name of choice, for example, let's use mango (yes, I love mangoes). Copy all the remaining files and folders (app, system, writables, env, LICENSE, README, composer, phpunit, spark) into the mango folder. After doing this, we should have 2 folders: api and mango

  • Copy both folders to your live server cpanel root (Do not copy into public_html or www). Let them be on the same level as public_html

  • Open api/index.php and change $pathsConfig = FCPATH . '../app/Config/Paths.php'; to $pathsConfig = FCPATH . '../mango/app/Config/Paths.php';

  • Create a subdomain and point it to /api

  • Go to the api folder, duplicate the env file and rename it to .env

  • Open .env and look for app.baseURL=''. Remove the '#' to uncomment that line and the change it to app.baseUrl='http://subdomain' where subdomain is the subdomain you created above e.g http://api.example.com

  • Open mango/app/config/App.php and look for public $baseUrl and set it to subdomain e.g $baseUrl = 'http://api.example.com'

  • Your CI project is now well configured. Visit http://api.example.com. and you should see the CodeIgniter welcome page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.