user_1234
user_1234

Reputation: 761

Codeigniter Rest api not working in http or http case

I am working on codeigniter api,after completing API I have uploaded code to server and all apis working but all of the sudden api showing error "unkown method" I am using "http://example.com/app/ws" so getting error, If I use "https://example.com/app/ws" api working I need api it should work if I use http or https because some time ssl certificate expire in that https nworking and if domain in https then http not working I need http or https both should work how to do this using .htacess I am attaching my code in .htaccess file

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

Upvotes: 0

Views: 289

Answers (1)

Mentega Terbang
Mentega Terbang

Reputation: 148

Are you trying to get the api from another CodeIgniter application? If yes, you may try this on the 2nd app :

$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  

$json   = file_get_contents('http://thelink', false, stream_context_create($arrContextOptions));

$data   = json_decode($json, true);

Upvotes: 1

Related Questions