Organiccat
Organiccat

Reputation: 5651

Remove index.php from codeigniter in xamp

I've tried quite a few answers but keep coming up against the good ol, 404 wall of terror. I'm on Windows 7 using a xamp stack. mod_rewrite is enabled.

I put the htaccess file in the main "codeigniter" directory, that is, the directory with application, system and user_guide. Should I put it under the application directory instead? The one with the views/model/config/etc.?

Here is my current .htaccess file:

RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/

RewriteBase /website/codeigniter/

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule .* index.php/$0 [PT] 

Accessing http://localhost/website/codeigniter/index.php/welcome works Accessing http://localhost/website/codeigniter/welcome does not

My config.php has

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

Any help greatly appreciated!

The error is:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

Error 404

UPDATE Oh, just thought about looking in apache logs, getting this error:

[Thu Mar 08 18:28:25 2012] [error] [client ::1] File does not exist: C:/xampp/htdocs/website/codeigniter/welcome

So it appears not to be picking up the proper codeigniter redirection? Not sure?

Upvotes: 3

Views: 8424

Answers (7)

NomanJaved
NomanJaved

Reputation: 1380

I was facing the same error again and again but after little research, I found a solution.

<IfModule mod_rewrite.c>

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

</IfModule>

The important point is, the project folder. Like I use RewriteBase /Codeigniter_start/ and RewriteRule ^(.*)$ /Codeigniter_start/index.php/$1 [L,QSA].

Also change from config file index_page like this.

 $config['index_page'] = '';

Hope this will help.

Upvotes: 2

John Yin
John Yin

Reputation: 8367

Firstly, enable "rewrite module' of apache in XAMPP

If you are using XAMPP or WAMP package then you will find the file at:

{xampp_dir}/apache/conf/httpd.conf
{wamp_dir}/apache/conf/httpd.conf

Find following line and remove the ‘#’ sign.

LoadModule rewrite_module modules/mod_rewrite.so

Actually, we can do upper by XAMPP popup menu: Apache -> Apache Modules -> rewrite module, and select it so as to enable it.

Secondly, we need change the htaccess by following:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

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

Upvotes: 0

Hieu Van Mach
Hieu Van Mach

Reputation: 683

Try this:

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

change to

$config['index_page'] = '';

Upvotes: 3

rash111
rash111

Reputation: 1317

first create .htacess file and paste below code in that RewriteEngine on

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

then go to config file

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

change to

$config['index_page'] = '';

and enjoy

Upvotes: 5

Christian Giupponi
Christian Giupponi

Reputation: 7618

have you enabled the mod_rewrite in apache?

Upvotes: 2

Catfish
Catfish

Reputation: 19294

Also try changing your request method in your config file from AUTO to REQUEST_URI.

Upvotes: 0

simnom
simnom

Reputation: 2620

Try changing the last line of your htaccess to:

RewriteRule .* index.php/$1 [L] 

Upvotes: 0

Related Questions