4

I am working on codeigniter 3.1.6.

I added the .htaccess file. I also changed the base_url path to my project path, removed the index.php from index_page and changed the url_protocol to REQUEST_URI.

Still, while I am redirecting the url to any controllers method it throwing an error as 'The page you requested was not found.'

I also searched and applied different .htaccess but its not working. If I am addling /index.php at end of base_url then its working but its wrong though. It should work without index.php.Only 3.1.6 giving this issue.

note: codeigniter-3.1.4 is working properly only this version is giving an issue

Mohammed Sabir
  • 157
  • 2
  • 2
  • 17

5 Answers5

3

Change folder name CodeIgniter-3.1.6 to ci

Set your base_url to

$config['base_url'] = 'http://localhost/ci/

Use this .htaccess

RewriteEngine On
RewriteBase /ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Yadhu Babu
  • 1,503
  • 2
  • 13
  • 25
  • Awesome bro, it works. But it is all going on? Die to missing `RewriteBase /ci` ? For other version I havent use such line still they are working fine? How? – Mohammed Sabir Oct 07 '17 at 05:22
  • Awesome. The .htaccess file to edit should be the one in the root folder. Not the one in the application folder – Martin Mbae Jul 27 '20 at 09:55
2

Use this script in .htaccess

<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 /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)

  RewriteRule ^(.*)$ index.php?/$1 [L]
  # If your root folder is at /mypage/test1/
  RewriteRule ^(.*?)$ /mypage/test1/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.
 # Submitted by: ElliotHaughin

  ErrorDocument 404 /index.php
 </IfModule>

Remove index.php from config.php $config['index_page'] = '';

Harish
  • 462
  • 6
  • 13
Sunday Okoi
  • 303
  • 2
  • 7
1

1) Edit config.php

 $config['index_page'] = 'index.php';

To

 $config['index_page'] = '’;

2) Create/Edit .htaccess file

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

1:Create .htaccess file in root directory not another project folder directory.

2:write or copy this code and paste it

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

I hope this will work properly. Go In Config file and make changed $config['url_protocol']='auto';

0

Additional tip: make sure .htacces in the root folder not inside >application folder

munyao
  • 1
  • 1