Hello all,

This is my first site project using codeigniter.

The frontend is all html and I am using codeigniter for the backend.

Everything was working fine until I added the frontend files and modified my htaccess file to not redirect to index.php but instead to index.html.

htaccess looks like this

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !/(front_assets|back_assets)/
#RewriteRule ^(.*)$ ./index.php/$1 [L]

This works okay but now from the frontend when I want to access the codeigniter stuff, it access the php file just fine but I cannot access my other views/etc..

So what I then did was changed htaccess back to

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !/(front_assets|back_assets)/
    RewriteRule ^(.*)$ ./index.php/$1 [L]

and in my header inside of codeigniter redirected back to the index.html if the user was not logged in, but now i get a 404 back the other way! However everything else through codeigniter works at this point...

I am confused.

Right now my htaccess file is back to

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !/(front_assets|back_assets)/
    #RewriteRule ^(.*)$ ./index.php/$1 [L]

I essentially want to load the frontend first and then load codeigniter when the user has logged in and been authenticated.

Any help is appreciated, thanks!

You can check the site out at http://ccc.the-prototype.com click log in from the main page to access the backend codeigniter.

You could move CodeIgniter to a subdirectory:

/index.html
/backend/index.php
/backend/system/
/backend/application/

Create an .htaccess file inside backend and change the rewrite rule to match the directory:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /backend/index.php/$1 [L]

A part from this solution, keep in mind that you can create simple Controllers and Views to run the frontend.

Thanks

Okay, I tried to copy everything (backend) over to /dev/ and kept getting a blank page. I am working on this project with another fellow and he is building the front end so they need to in essence run seperately.

I can echo stuff out on the /dev/index.php page so I know I am in the right location however it doesn't appear to be loading the other modules right.

UPDATE:

I can now get codeigniter to work under /dev/ but only the dashboard/index.php page again... Is there somewhere to set codeigniter directory path?

I DID set them in the index.php to /dev/system and /dev/application.

I DID also set the base_url under the /dev/application/config/config.php file.

My links were referring to root directory on menu's.... This has been fixed. Thank you Cereal.

You don't have to change anything, the paths are relative to the file index.php so, unless you have system and application directories into another directory, don't change the values of those variables. Remember also to not include trailing slashes, otherwise it doesn't work:

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

As suggestion create a test controller and check if it loads fine:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller {

    public function index()
    {
        $this->load->view('test_index');
    }
}

and the relative view in views/test_index.php:

<?php

    echo 'hi!';

If still it doesn't work change the environment value to development, inside index.php:

    define('ENVIRONMENT', 'development');

and retry, if it does not work check CodeIgniter, PHP and Apache logs for errors.

EDIT
Ok, glad you solved, bye!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.