Himanshu Pandey
Himanshu Pandey

Reputation: 1280

Hide codeigniter folder name when folder is subfolder of another php application

I have core php application and codeigniter in subfolder of this application. i want to hide CI folder name for a single controller . just like

The original url is http://example.com/ci/welcome/test

and the excepted URl is

http://example.com/welcome/test

what is the htaccess base solution for this

Upvotes: 2

Views: 1185

Answers (3)

netto
netto

Reputation: 135

Try these

RewriteRule ^(.*)$ ci/$1 [L]

Upvotes: 0

Himanshu Pandey
Himanshu Pandey

Reputation: 1280

I got solution

  1. in htaccess

RewriteRule ^([a-zA-Z0-9-_']+)/([a-zA-Z0-9-_']+) ci/$1/$2 [L,NC,QSA]

  1. on index.php last line change require_once BASEPATH.'core/CodeIgniter.php'; to require_once APPPATH.'core/CodeIgniter.php';

3 on APPPATH.'core/CodeIgniter.php' search $RTR and put this code behind

if( $RTR->class =='mainfoldername' ){
            $RTR->class =$RTR->method;
            $RTR->method = $RTR->uri->rsegments[3];
            $total_segment = count( $RTR->uri->segments );
            foreach( $RTR->uri->segments as $k=>$uri  ){
                if( $k != $total_segment ){
                    $RTR->uri->segments[$k] = $RTR->uri->segments[$k+1];
                    $RTR->uri->rsegments[$k] = $RTR->uri->rsegments[$k+1];
                }
            }

        }

Upvotes: 0

Pardeep Pathania
Pardeep Pathania

Reputation: 1528

please use this :

RewriteEngine On
RewriteRule ^ci/(.*)$ /$1 [L,R=301,QSA]   

Upvotes: 1

Related Questions