0
votes

I'm trying to create a web-based Codeigniter , but I found the problem when my website , I put online

This my .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And this is my config :

$config['uri_protocol'] = 'PATH_INFO';

And this my Routes.php

$default_controller = "Front";
$controller_exceptions = array('owner');

$route['default_controller'] = $default_controller;
$route["^((?!\b".implode('\b|\b', $controller_exceptions)."\b).*)$"] = $default_controller.'/$1';
$route['404_override'] = '';

And this is my Controller class :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Front extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
    }

    public function _remap($segment_1)
    {       
    $segment_1 = $this->uri->segment(1);
    switch ($segment_1)
     {
        case null:
        case false:
        case '':
        $this->load->library('Facebook_ion_auth');
        if (isset($_GET['code']))
            {
            $this->facebook_ion_auth->login();
            if (!$this->ion_auth->logged_in()){
                $this->index();
            }else{
                $succses='Selamat datang! <b>'.$this->ion_auth->user()->row()->user_display_name.'</b>';
                $content = new Content();
                $content->profil($succses,'');
            }
        }else{

            $url =  $this->uri->segment_array();
            print_r($url);
        }

        break;

        case 'category':
            $this->category();
        break;

        case 'search':
            $content = new Content();
            $content->search();
        break;  

        case 'pesan':
            $content = new Content();
            $content->pesan();
        break;

        case 'daftar':
            $content = new Content();
            $content->daftar();
        break;

        case 'login':
            $content = new Content();
            $content->login();
        break;

        case 'keluar':
            $content = new Content();
            $content->keluar();
        break;

        case 'profil':
            $content = new Content();
            $content->profil();
        break;

        case 'kirimpesan':
            $content = new Content();
            $content->kirimpesan();
        break;

        case 'contact':
            $content = new Content();
            $content->contact();
        break;

        case 'testimoni':
            $content = new Content();
            $content->testimoni();
        break;

        case 'facebook':
            $this->load->library('Facebook_ion_auth');
            $this->facebook_ion_auth->login();
        break;

        case 'img':
            $this->img();
        break;

        default:
        $content = new Content();
        $content->sigle();
        break;
        }
    }                                                                                                       

    public function index()
    {
        $content = new Content();
        $content->home();
    }
}

But it is always running case = "", That this proves that $segment_1 = $ this-> uri-> segment (1); could not be detected. or no data from uri 1.

$url = $this->uri->segment_array(); 
print_r($url); 

Displays DISPLAY EMPTY How to fix, order a URL can be detected. Or take the parameters from the URL??

1

1 Answers

0
votes

I don't understand what you want to do but it's will be nice if you provide your URI

is it ://site/ or ://site/Front ??

also remove this line

$segment_1 = $this->uri->segment(1);

because you already send it as a parameter in the _remap function

Note that if your url without class name and function like this ://site/ the

$this->uri->segment(1)

will equals false because segment doesn't exist in url