Search code examples
.htaccesscodeigniter

Codeigniter htaccess for multiple applications


Hello guys can you help me how set proper url in codeigniter using multiple applications and i proper .htaccess

Folder Structure

-application
 -api
 -cms
-system
-api.php
-cms.php

Its works when a use this

http://localhost/kitkat_funs/cms.php/
http://localhost/kitkat_funs/api.php/

But i want this

http://localhost/kitkat_funs/cms/
http://localhost/kitkat_funs/api/

My htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Solution

  • Please try following steps:
    In config=>config.php, replace like following.

    $config['index_page'] = 'index.php';
    

    to

    $config['index_page'] = '';
    

    Please put following code into your .htaccess file, this might help you to achieve the result.

    write your project folder name as rewritebase

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

    *take backup of your .htaccess file.