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

14

5 Answers 5

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]
2
  • 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? Oct 7, 2017 at 5:22
  • Awesome. The .htaccess file to edit should be the one in the root folder. Not the one in the application folder Jul 27, 2020 at 9: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'] = '';

1
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]
1
  • 1
    Not Working bro. Already done that. Only this version giving an issue. I am using this version for first time Oct 6, 2017 at 15:40
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.