2

.htaccess code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

also change in config file:

$config['index_page'] = ' ';

$config['uri_protocol'] = "REQUEST_URI";

mod_rewrite is also enabled. although this code doesn't work.

4
  • What apache server are you running wamp lamp etc
    – user4419336
    Commented Oct 1, 2015 at 4:49
  • apache server running...and server is in CentOS. Commented Oct 1, 2015 at 4:55
  • i am working with cassandra database Commented Oct 1, 2015 at 4:56
  • in cent os you have make a small change in ur httpd.conf file and take restart. .Htaccess won't work untill you make that change.
    – Bugfixer
    Commented Oct 1, 2015 at 7:14

4 Answers 4

0

Change this

In 'config.php`

$config['base_url'] = '';
$config['index_page'] = ''
$config['uri_protocol'] = 'AUTO';

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

and accessing URL should with base_url() function.

ex <form action="<?php echo base_url()?>Controller_name/Method_name"

Note: To use base_url() you have to enable it on autoload.php

$autoload['helper'] = array('url');
4
  • The requested URL was not found on this server Commented Oct 1, 2015 at 8:19
  • did you place my .htaccess ?? Commented Oct 1, 2015 at 8:21
  • my server is in CentOS. is there any problem with the server? Commented Oct 1, 2015 at 8:33
  • @RubbySmith Read this Commented Oct 1, 2015 at 8:39
0

You cannot use the REQUEST_URI protocol when you are asking Apache to send the URI to the QUERY_STRING.

So either change your .htaccess or your config so they match. My recommendation is to change .htaccess:

RewriteRule ^ index.php [L]
3
  • And what about using your previous .htaccess code and then changing the protocol from REQUEST_URI to QUERY_STRING? Commented Oct 1, 2015 at 5:17
  • Also, there's an unnecessary space in the index_page setting. Change ' ' to ''. Commented Oct 1, 2015 at 5:18
  • i have tried all the option of protocol but it can't work... i can't understand what is the problem Commented Oct 1, 2015 at 5:25
0

Have you tried giving AUTO instead of REQUEST_URI. Even i had a similar problem but got solved when i changed it to AUTO and small change in .htaccess in my case.

$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO';

.htaccess-

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

OR

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

If doesn't works for your case sorry.

CodeIgniter htaccess and URL rewrite issues

1
  • 1
    Note: Codeigniter 3 does not have AUTO.
    – user4419336
    Commented Oct 1, 2015 at 5:33
0

I have running CI 3 Application and working fine with this .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.