Skip to content

Removing index.php in codeigniter xampp for windows

World Wide Web Server edited this page Jul 4, 2012 · 8 revisions

Removing index.php in codeigniter xampp for windows

[color=green][b]***STEP 1:[/b]Create .htaccess using command prompt[/color]

To create .htaccess file in windows:

1.) Open Command Prompt 2.) In the command line, go to the directory or folder where you placed your root folder or codeigniter folder [quote] Example: [b]Command Prompt [code] C:\xampp\htdocs\site_folder [/code] [/b] [/quote]

3.) Type copy con .htaccess to create a .htaccess file in the folder

[quote] Example: [b]Command Prompt [code] C:\xampp\htdocs\site_folder copy con .htaccess [/code] [/b] [/quote]

4.) Press [enter]. A blank line after the command line appears

[quote] Example: [b]Command Prompt [code] C:\xampp\htdocs\site_folder copy con .htaccess | [/code] [/b] [/quote]

5.) Type the following code

[quote] [color=blue] [code] 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 /

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/$1 [PT,L] [/code] [/color] [/quote]

[color=red] NOTE: RewriteBase must be set to the folder or directory in which you place your CI folder [/color]

[quote] [color=purple]If your URL is www.example.com/ then use [b] RewriteBase / [/b] [/color] [color=purple] If your URL is www.example.com/site_folder/ then use [b] RewriteBase /site_folder/ [/b] [/color] [/quote]

6.) After typing the code above type [b] [color=blue] [ctrl]+Z [/color] [/b]

^Z will appear on the cmd line

 [b] [code] ^Z [/code][/b]

7.) Press [enter]. The .htaccess file is now saved in your site_folder not as a text file but as a .htaccess file.

[color=green] [b] ***STEP 2: [/b] Configure mod_rewrite in httpd.conf [/color]

1.) Locate your httpd.conf

[quote] Example: C:\xampp\apache\conf\extra\httpd.conf[/quote]

2.) Search for the line [code] [color=blue] #LoadModule rewrite_module modules/mod_rewrite.so [/color] [/code] 3.) Uncomment the line, into: [code] [color=blue] LoadModule rewrite_module modules/mod_rewrite.so [/color] [/code] 4.) Save Changes.

[color=green] [b] ***STEP 3: [/b] Configure config in you site_folder (codeigniter) folder[/color]

1.) Locate your config.php

[quote] Example: C:\xampp\htdocs\site_folder\system\application\config [/quote]

2.) Change [code] $config['index_page'] = "index.php"; [/code] to [code] $config['index_page'] = ""; [/code]

Clone this wiki locally