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

Hello everyone,
I have been stuck with this problem for hours, codeigniter only load the index of my default controller here i show you my code 
PHP Code:
                <li class="joinus">
 
                   <class="" href="<?php echo base_url('site/about');?>">Join us</a>
                </
li

my view where i call my function 
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');
    }

my controller
PHP Code:
RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteCond 
$!^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$[L
 and my .htaccess located in my root folder
my 'index.php' variable in conf is unset, my mod_rewrite on i tried each 'uri_protocol' and my 'base_url' is set like 'http://localhost:888/myapp' i also tried to modify my .htaccess but still the same problem ci load only the same index of my main controller and i cant call any others functions
Reply
#2

(This post was last modified: 02-29-2016, 08:01 PM by siburny.)

If CI is in subfolder I think you have to set RewriteBase:
RewriteBase /myapp/

Put it right after RewriteEngine
Reply
#3

(This post was last modified: 03-04-2016, 01:06 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.

http://phpclicks.com/codeigniter-remove-...-from-url/
http://phpclicks.com/codeigniter-seo-friendly-urls/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB