Welcome Guest, Not a member yet? Register   Sign In
urlrewriting htaccess not working
#1

Hello,
I have some trouble with the url rewriting, it only load my index function of my default controller and dont load any other function when i change the url or call a function everything i do it will always stay on my index of my default controller, if anyone have an idea what it could be. I am really lost on this problem. i set up the url rewriting my config variable 'index' empty, my base_url set up, i tried each uri_protocol i show you my .htaccess located in the root file of my view and my controller:


PHP Code:
class Site extends CI_Controller 
{
    public function 
__construct()
    {
        
parent::__construct();
    }

    public function 
index()
    {
        
$this->load->view('header.php');
        
$this->load->view('home.php');
        
$this->load->view('footer.php');
    }

    public function 
about()
    {
        
$this->load->view('header.php');
        
$this->load->view('about.php');
        
$this->load->view('footer.php');
    }


PHP Code:
                <li class="joinus">
 
                   <class="" href="<?php echo base_url('site/about');?>">Join us</a>
                </
li

Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Reply
#2

(This post was last modified: 03-04-2016, 01:08 PM by mfiaz. Edit Reason: Formatting Issue )

Hi, 

Just follow my below steps.

First

Inside application/config/config.php find below line

Step 1. 
PHP Code:
$config['index_page'] = 'index.php'


replace it with this one

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


Find below line


PHP Code:
$config['uri_protocol'] = 'AUTO'


Replace it with 

PHP Code:
$config['uri_protocol'] = 'REQUEST_URI'


Step 2 

Place below code in your .htaccess file

Code:
RewriteBase /your-project-directory-name/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]


if your project is inside sub directory then you need to minor change in .htaccess file rules that will be ” RewriteBase / ” to ” RewriteBase /subdir/ ”

You can get full detail from below link on how to remove index.php from URL and write seo friendly URL's in Codeigniter.

Codeigniter Remove index.php from URL
Codeigniter URL re Writing 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB