Welcome Guest, Not a member yet? Register   Sign In
Removing index.php but different
#1

[eluser]llamasam[/eluser]
Hi,

I have managed to get the .htaccess file working with mod rewrite so that pages such as "http://example.com/forums/newtopic/" will work. However... if i were to type "http://example.com/index.php/forums/newtopic/" i will get the same content.

How do i redirect from a url containing index.php yet still send requests to the file without getting stuck in an infinate loop?

Im not sure if i have worded it in a very coherent manner so if anyone doesn't understand this please let me know so that i can approach the wording from a different angle.
#2

[eluser]bubbafoley[/eluser]
as long as you have

Code:
$config['index_page'] = '';

you can check for index.php in a base controller and then redirect

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        
        if(preg_match('/index\.php/', $_SERVER['REQUEST_URI']))
        {
            redirect(uri_string());
        }    
        
    }
}

then have your controllers extend MY_Controller instead of CI_Controller

Code:
class Forums extends MY_Controller {
...
#3

[eluser]llamasam[/eluser]
Nice one, works perfect, except for on non existent pages but i don't see that as a problem.

Thanks for that




Theme © iAndrew 2016 - Forum software by © MyBB