Bhavin
Bhavin

Reputation: 2158

.htaccess not working in codeigniter

I just live my website. Website Link is : http://cmexpertiseinfotech.in/pos1/ it's working fine in localhost.My .htaccess file is,

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /pos
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.

  ErrorDocument 404 /index.php
</IfModule>

So in htaccess i'm checking that rewrite mode enable or not ? But it's not working it's showing 404 page. I have put my .htaccess of main directory like this,

Directory Structure,

-application
     -.htaccess // this .htaccess has no content (Deny from all )
-system
-user_guide
-public
-.htaccess // this .htaccess's content is show above.

base_url() is :

$config['base_url'] = 'http://cmexpertiseinfotech.in/pos/';

EDIT : I just request for rewrite mode enable to my head but it takes 1-2 days so i'm trying another thing and I just removed .htaccess file from project on root directory.

This is working. please visit this link : http://cmexpertiseinfotech.in/pos/index.php/welcome/index.

but this is not working. http://cmexpertiseinfotech.in/pos/index.php/home/login.

Controller :

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

class Home extends CI_Controller {

    public function login()
    {
        $this->load->view('login');
    }
}

View : Login.php

<h1> Login </h1>

Upvotes: 1

Views: 1160

Answers (1)

Ben Hillier
Ben Hillier

Reputation: 2104

You're mixing up two questions here:

  1. Is mod_rewrite installed/enabled ?
  2. Is the Rewrite Engine on/active ?

This line checks if it's installed and loaded: <IfModule mod_rewrite.c>.

Only if it's loaded does Apache then turn it on with: RewriteEngine On.

Since it seems not to be installed or enabled here, you need to solve that. But you (or someone) will need root permission on the server, and then you need to find the Apache configuration file.

Is this hosted by a provider

You need to ask them to enable mod_rewrite

If you can get to the file

Unless Apache was very restrictively installed, you should be able to find the following line:

#LoadModule rewrite_module modules/mod_rewrite.so

Enable it by removing the #. Then restart Apache.

It's hard to go into specific commands here, because there's so much variation in how Apache is installed.

Upvotes: 1

Related Questions