5

I have a little project that i developed for a client in codeigniter 2.1.4 and now, he insists to migrate to codeigniter 3 DEV version. I know that's not a good ideea but... My problem is that i can't remove the index.php from the url.

This is my .htaccess file :

  Options +FollowSymLinks
  RewriteEngine on

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

I have removed the index.php from the config.php file
No luck
I reinstalled the LAMP server (i'm on Ubuntu 12.04'), reconfigured
I have other projects on my local server developed on Codeigniter 2.1.4 and Laravel 4 and they work just fine but this one it's killing me.
Thank you!

5
  • Just out of curiosity: How is it that your client can differentiate between version 2 and 3 but cannot convert themselves? Commented Nov 24, 2013 at 0:20
  • @php_nub_qq ya, anyways i am reading what CI3 is all about :@ Commented Nov 24, 2013 at 0:21
  • 1
    He can not but someone shoved this thing in his head. Commented Nov 24, 2013 at 0:24
  • Here are a couple of resources that actually show the code without a question mark. See if any of these help madhukaranand.wordpress.com/2013/09/08/codeigniter-urls ellislab.com/codeigniter/user-guide/general/urls.html Commented Nov 24, 2013 at 0:35
  • I've already tried this option... Commented Nov 24, 2013 at 0:47

10 Answers 10

11

I made this way:

Created the .htaccess in the root folder of the project with the content:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ index.php?$1 [L]

Then, in the config.php i modified this line.

From:

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

To:

$config['url_suffix'] = '';
Sign up to request clarification or add additional context in comments.

Comments

6

Kindly add the below codes to .htaccess file and include it directly to your /codeigniter_project_folder/.htacess

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

Comments

2

If your Apache server has mod_rewrite enabled, you can easily remove this file by using a .htaccess file with some simple rules.

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

Remove the ? after index.php

Comments

2

Add following lines in .htaccess file

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

And also Edit application/config/config.php file. with

$config[‘index_page’] = “”;
$config[‘uri_protocol’] = “AUTO“;

It will Work.

Comments

1
  1. Make a .htacess file in your project root folder /Your_codeigniter_project_folder/.htacess and paste this code

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php/$1 [L]

  2. set a base URL in config.php file $config['base_url'] = 'http://yourhost/CI_project_folder/';

  3. set URL suffix $config['url_suffix'] = '.php';

* If not work please check this *

  1. Make sure in your root folder where .htacess stay there have not any file which name is same like your controller name. Example: you have a users.php controller also you have a file in /Your_codeigniter_project_folder/users.php If have please remove it /Your_codeigniter_project_folder/users.php

  2. Make sure your server is rewrite mode on( remove # from start of this line)

    LoadModule rewrite_module modules/mod_rewrite.so

Comments

0

create new .htaccess file on root of your CI project and add your code there. Do not change .htaccess file on application folder. That's work for me

Comments

0

Just Download CI version 2.2.0

Copy .htaccess and htaccess.txt from root and paste it in your Codeigniter 3 project.

Don't forget to change project name from .htaccess file.

Comments

0
  1. Create an a new htaccess file in your www/project_folder or your htdocs/project_folder

  2. Make sure mod_rewrite is working my using echo phpinfo()

  3. Simply paste the following code and it should work:

    <IfModule mod_rewrite.c>
    
        RewriteEngine on
        RewriteCond $1 !^(index\.php|images|robots\.txt)
        RewriteRule ^(.*)$ /project_folder/index.php/$1 [L]  
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        ErrorDocument 404 /index.php
    </IfModule>
    
  4. Change the project folder to that of your own

Comments

0

Be careful about the project path uppercase. i.e. if the base_url is http://localhost/ci/ and the directory name is CI, it may not work.

Comments

-1

I have clone the git repository again and made a clean install of the lamp and now it works.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.