CodeIgniter Forums
use CI as micro engine without views folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: use CI as micro engine without views folder (/thread-67856.html)



use CI as micro engine without views folder - ardavan - 04-18-2017

Hi guys,

I'm working on a project which is an engine to do something based on inputs.
This project is using controller and model only to read / save manipulated data or return some results to the referrer URL.

I wanna hide this engine-CI view pages from users who wants to have direct access to the views or search engines.
My question is how to delete/redirect/block the direct URLs to my engine-CI?

Thanks guys


RE: use CI as micro engine without views folder - neuron - 04-18-2017

You need to implement authorization methods in engine-CI. 

you can build engine-CI as an ReSTful api 
https://github.com/chriskacerguis/codeigniter-restserver


RE: use CI as micro engine without views folder - ardavan - 04-18-2017

(04-18-2017, 03:21 AM)neuron Wrote: You need to implement authorization methods in engine-CI. 

you can build engine-CI as an ReSTful api 
https://github.com/chriskacerguis/codeigniter-restserver

I'm planing to make the CI as an API but what will happen if user directly insert http:// example.com/engine/ then the CI will display the default route which is 'welcome'. I wanna screw the view or direct access like http://example.com/engine/reports

Sorry maybe my question sounds silly but it's my first time to do this. Please guide me more

Thanks


RE: use CI as micro engine without views folder - neuron - 04-18-2017

I am also noob Smile

how about filterin by IP in htaccess ? or in index.php  check remote IP address.

if u implement ReST API. rest server this library has built in authentication methods. in rest library config u can set valid user that are able to connect to ur engine-ci api
$config['rest_valid_logins'] = ['admin' => '1234'];
or u can set IP whitelist $config['rest_ip_whitelist_enabled'] = FALSE;

if connection is not secure (not https) $config['rest_valid_logins'] = ['admin' => '1234']; is not secure


RE: use CI as micro engine without views folder - xenomorph1030 - 04-18-2017

You can change the default route in config/routes.php and point it to a controller with a method which uses show_404() if that is the desired effect (https://codeigniter.com/user_guide/general/errors.html?highlight=#show_404).