How to remove index.php within codeigniter on different port

500 Views Asked by At

removing index.php on codeigniter are found easy using .htaccess,

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

but when needed to be on other ports? it doesn't work, why? and how to make it work?

in http://localhost:85/foldersite seems working, but when calling a controller it's not found, such as http://localhost:85/foldersite/mycontroller

yet the same .htaccess when deployed in server hosting these are just fine calling the controller because it didn't use any different port than 80 ..

and in file config.php and route.php already set as follows

 $config['base_url'] = 'http://localhost:85/foldersite';
 $config['index_page'] = '';
 $config['uri_protocol']    = 'REQUEST_URI';


 $route['default_controller'] = 'welcome';
 $route['404_override'] = '';
1

There are 1 best solutions below

0
Insan Jati On

I think I just have the same issue as yours, and I managed to solve it just about couple of minutes ago.

Please consider to read this documentation page: CodeIgniter URLs. Under the section of "Removing the index.php file" you'll be informed about Apache mod_rewrite enabled.

Then, I implemented a tutorial from Digital Ocean and it worked well. Just try it.

In addition, I have .htaccess content that exactly the same with yours. Except, I didn't modify any value from $config['base_url'] and $config['index_page'].

I hope it helps.