Index.php removal - official guide not working (code igniter)

I am trying to remove index.php in url for Code Igniter. According to the official guide, I have to add the following code to the .htaccess file.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

This does not work.

So, I make more requests, and some say that I should delete the default configuration on the index page, so I make changes to the config.php file:

$config['index_page'] = '';

It still does not work. Then, on other searches, I found another version of the code, like this one (there is only an example, I have already tried many versions)

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

I originally put the code in the .htaccess root directory, but since it does not work, I will also try adding it to the .htaccess in another directory. However, still not working.

, , . .

http://localhost/projectFolder/CodeIgniter/welcome/

- , ?

0
3

, , http://localhost/projectFolder/CodeIgniter/, docroot .htaccess .

, , apache. , .htaccess, Directory - AllowOverride All.

, .

+1

,

RewriteEngine on
RewriteCond $1 !^(index\.php|css|js|public|themes|captcha|robots|documents|\.txt)
RewriteRule ^(.*)$ /projectFolder/index.php/$1 [L]

, .

0

 $config['base_url'] = 'http://localhost/projectname/';
 $config['index_page'] = '';

ur.htaccess

 DirectoryIndex index.php
 RewriteEngine on
 RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 

, apache mod_rewrite

The .htaccess file should be in the root directory of your project, i.e. the external folder of the application

0
source

All Articles