Multiple apps Codeigniter: remove index.php/controller from URL

I am new to CodeIgniter and trying to understand the basics and maybe some advance methods to set an MVC based application. After a while I thought i might get a try to set a admin pannel as well and created and second folder as admin application.

This is my folder structure:

www.domain.com
    --frontend
    --admin

In each folder is an app set with it’s own .htaccess file. Bellow is the .htaccess file for admin side.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /admin/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

</IfModule>

Current working url is www.domain.com/admin/index.php/admin/posts
and I am trying pointless to change it to www.domain.com/admin/posts. So how do I remove the /index.php/admin from url.

The $config[‘base_url’] is set accordingly for each side(admin/frontend) and the default index.php is set null also , $config[‘index_page’] = ”;

Is this the problem cause I have 2 different apps or just a bad configuration?
What is the best practice with multiple apps same site?

Hope i did not duplicated any post and if so please don’t hate and try to help me. I am deeply grateful to all of you.


Source: .htaccess

1 Comment

  1. Digin Dominic

    Try this

    in config.php

    $config['base_url'] = '';
    $config['index_page'] = '';

    in .htacess

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]


    EDIT 01

    <link href="css/style.css" rel="stylesheet" />

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.