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.

Nirali Kavar
  • 956
  • 2
  • 8
  • 17

4 Answers4

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]
Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81
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

Community
  • 1
  • 1
Sanjuktha
  • 1,065
  • 3
  • 13
  • 26
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>
Rana Soyab
  • 898
  • 5
  • 20
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');
Community
  • 1
  • 1
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85