Remove index.php from codeigniter url

I am new to codeigniter. I have code installed on localhost / path / learn_ci.

I followed all the steps in the codeigniter wiki. Here is my .htaccess file.

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

I also changed the configuration file as needed. But when I try to access

I get this error

"The requested URL / learn_ci / index.php / welcome was not found on this server"

I checked twice ... the mod_rewrite module in Apache is enabled.

The RewriteBase solution also does not work. Am I doing something wrong?

+4
source share
6 answers

As others have said, make sure that the AllowOverride parameter is set to All in the apache configuration or in the virtual host file. If you specify the path where you have the encoding installed, your htaccess should look like this:

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

Also remember that any resources you use (img, css, js, etc.) refer to either the base_url() function or the use of relative paths. The root of your project will be / path / learn _ci.

I find it easier to create a virtual host and add an entry to my hosts file locally. It reflects real life much better.

+2
source

Try:

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

You can do the following:

First in config.php file

 $config['index_page'] = ''; 

Then create a .htaccess file in the codeigniter root folder and add the following content:

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

Save the file. It should work.

+1
source

You put the htaccess file in the public_html root folder in the same directory as index.php

Then remove / learn _ci from your htaccess file, just do this / index.php / $ 1

0
source

Check your Apache configuration, it should look something like this:

 Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all 
0
source

I thought to add my answer. My project url is http://localhost/newproject/ I have included the htacess file in the newproject folder.

here is the code.

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

then I change the configuration file.

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

and it all started to work. Now nomore index.php file.

0
source

All Articles