简体   繁体   中英

How to remove index.php within codeigniter on different port

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'] = '';

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM