Welcome Guest, Not a member yet? Register   Sign In
Catch n check $this->uri->segment(?)
#1

[eluser]Circuitbomb[/eluser]
Ok so maybe my title was a bit confusing.

Using the default controller set in CodeIgniter I'm looking to catch a url similar to

http://mysite.com/index.php/4348q34

using code that looks like:

Code:
if($this->uri->segment(1) === TRUE) {
            
            if(!method_exists(__CLASS__, $this->uri->segment(1)) || !method_exists(__CLASS__, $this->uri->segment(2))) {
                    //echo $this->uri->segment(1);
                    $this->my_lib->my_method($this->my_lib->my_method($this->uri->segment(1)));
                    
            } else {
                
                return;
                
            }
        } else {
            
            return;
        }

in the construct of the default controller.

my_library is being loaded.

Basically, what im trying to do is check to see if the uri segment 1 or 2 exists within the default controller, and if it doesnt to process a method in my library to initialize a redirect to an external site.

any ideas?
#2

[eluser]Circuitbomb[/eluser]
Ok I managed to hack it up looking at

http://ellislab.com/forums/viewthread/103349/P30/

and sending the request to a function that looks like

Code:
function process($string) {    
        
        if(preg_match('|^[0-9a-zA-Z]{1,6}$|', $string)) {
            
            $this->load->library('my library');
            $this->my_library->process_request($this->uri->segment(1));
            
        }
    }

It looks good so far, except I don't get the 404's from no match uri's in which case i can simply direct it in else.




Theme © iAndrew 2016 - Forum software by © MyBB