Viewed   61 times

when I had my site on development environment - it was url:

Now on production server my codeigniter app's address has to be

I moved it there, and everytime I'm trying to run some function, example /home/test - it gets me into - which is WRONG.

It has to be - How to fix it? I did set

$config['base_url'] =



Base URL should be absolute, including the protocol:

$config['base_url'] = "";

If using the URL helper, then base_url() will output the above string.

Passing arguments to base_url() or site_url() will result in the following (assuming $config['index_page'] = "index.php";:

echo base_url('assets/stylesheet.css'); //
echo site_url('mycontroller/mymethod'); //
Sunday, October 16, 2022

In Config.php

$config['base_url'] = 'http://localhost/Appsite/website/';
$config['index_page'] = '';

# If online site
# $config['base_url'] = 'http://.com/';

In .htaccess (outside application folder) - To remove index.php in URL

RewriteEngine on
RewriteCond $1 !^(index.php|assets|image|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

To accessing URL

<a href="<?php echo base_url();?>contollerName/methodName"> click here</a>

To access image

<img src="<?php echo base_url();?>images/images.PNG”>

To access CSS

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/style.css"/>

To use base_url load URL helper from autoload.php

Sunday, August 21, 2022

Hm, understand. As I see the subquery's source code in line 27, it wants to call _compile_select or get_compiled_select. If you can check in CI's DB_active_rec.php the _compile_select is protected so you can't access from Subquery (it isn't subclass of db).

Possible solution: _compile_select() should public or class Subquery should be extend of CI's db class. I think you should report this to author of Subquery.

Or you can extend the CI's db class :)

Sorry - I want to write it as a comment.

Sunday, December 18, 2022

Try this code it might help you :

Here dashboard is the name of controller

//this will route as localhost/appFolder/admin/index
  $route['admin'] = 'dashboard'; // for your index page

//this will route as localhost/appFolder/admin/method_name
 $route['admin/(:any)'] = 'dashboard/$1';

//this will route as localhost/appFolder/admin/method_name/param1
$route['admin/(:any)/(:any)'] = 'dashboard/$1/$2';

Link the route Like

// for your index page
<a href="<?php echo base_url('admin/index'); ?>"></a>

// for your other pages
<a href="<?php echo base_url('admin/method_name'); ?>"></a>

To link the other controller defined just like

 <a href="<?php echo base_url('otherControllerName/method_name'); ?>"></a>
Sunday, September 4, 2022

I personnaly do this kind of stuff with grunt.

When I run my angular-app I have multiple tasks :

> grunt run --target=dev
> grunt run --target=prod
> grunt build --target=dev
> grunt build --target=prod
> etc...

Then grunt do strings replacement with the help of the grunt-preprocess module :

my constants.tpl.js file gets parsed :

baseUrl:           '/* @echo ENV_WS_URL */',

and the url is populated.

There are endless possibilities (string replacements, file copy, etc).

Doing it with grunt ensure that dev config files do not go in production for example..

I can put more details if you're interested but I only wanted to show you a different approach.

edit gruntFile example :

'use strict';

module.exports = function(grunt) {

     * Retrieving current target
    var target = grunt.option('target') || 'dev';
    var availableTargets = [

     * Load environment-specific variables
    var envConfig = grunt.file.readJSON('conf.' + target + '.json');

     * This is the configuration object Grunt uses to give each plugin its
     * instructions.
        env: envConfig,       

        /* Build files to a specific env or mode */
        preprocess: {
            options: {
                context: {
                    ENV_WS_URL: '<%= env.wsUrl %>'
            constants: {
                src: 'constants.tpl.js',
                dest: 'constants.js'

        karma: {
            unit: {
                configFile: '<%= src.karma %>',
                autoWatch: false,
                singleRun: true
            watch: {
                configFile: '<%= src.karma %>',
                autoWatch: true,
                singleRun: false


    /* Plugins load */

    /* Available tasks */
    grunt.registerTask('run', 'Run task, launch web server for dev part', ['preprocess:constants']);


Now, the command :

> grunt run --target=dev

will create a new file with an url

Wednesday, September 28, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :