V15HM4Y
V15HM4Y

Reputation: 1805

CodeIgniter: removing 'index.php' from URL

I have answered this question previously and even posted the answer to it by myself. I tried most of the answered questions, but it still didn't work. The first question is regarding placement of the .htaccess file, should I keep it with application folder or inside it? and the next question is 'How should I remove the index.php from URL'?

.htaccess code:

RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Config.php code:

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

and if possible do also suggest a detailed tutorial regarding how to customize TankAuth or any other authentication library which can be easier. I am using Windows 8.1 and Wamp Server.

Any suggestion or help is appreciated.

Upvotes: 0

Views: 4184

Answers (7)

adikur
adikur

Reputation: 11

it works on me, I use v2.2.6 by the way

  • Create .htacccess on the same dir as your index.php
  • Modify index_page and base_url value in /application/config/config.php

here is what it looks like

picture image link

Upvotes: 1

shafi
shafi

Reputation: 310

1.config.php

$config['index_page'] = 'index.php';     change  to     $config['index_page'] = '’;

2.Create .htaccess file

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

Upvotes: 0

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

in config.php change this

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

and in .htaccess(NOTE: this should be place outside application folder)

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

Note: There are lot of duplicate question. So before Ask New Question please check your dropdown menu(its comes with when you start typing title of your question) whether its exist or answer provided.

Upvotes: 0

Anshar Firman
Anshar Firman

Reputation: 41

i think it will help you,

.htaccess

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

in config.php

    $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://';
    $newurl = str_replace('index.php', '', $_SERVER['SCRIPT_NAME']);
    $config['base_url'] = "$http".$_SERVER['SERVER_NAME'].''.$newurl;
    $config['modules_locations'] = array('http://localhost/astrido_admin/application/' . 'modules/');

$config['index_page'] = '';

Thanks

Upvotes: 0

user4419336
user4419336

Reputation:

Try this htaccess works fine windows 7 and 8.1 and xampp

Make sure you place the .htaccess in main directory and not the application folder.

Options +FollowSymLinks
Options -Indexes

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

Config

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

More htaccess https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter

Upvotes: 0

KBK
KBK

Reputation: 375

enter image description here

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

application > config > config.php

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

definitely it will work.

Upvotes: 0

sonam gupta
sonam gupta

Reputation: 785

Use this in your .htaccess file:

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

place ./ before your index.php rewrite rule.

or this

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


For more detail refer link:https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html

Upvotes: 1

Related Questions