Skip to content

Removing index.php from a URL path in XAMPP for Windows

SoftwareSpot Apps edited this page Aug 24, 2015 · 2 revisions

Removing index.php from a URL path in XAMPP for Windows

STEP 1: Create .htaccess using the command prompt in Windows

  1. Open command prompt

  2. In the command prompt, change the working directory to the CodeIgniter directory i.e. the directory that contains the application and system directories

    cd C:\xampp\htdocs\site_folder

  3. Type copy con .htaccess to create a .htaccess file in the current working directory

  4. Press [ENTER] to append an empty line

  5. Type the following code:

    RewriteEngine On
    
    # The base URL path
    # If your URL is www.example.com/, then use /
    # If your URL is www.example.com/site_folder/www, then use /site_folder/www/
    RewriteBase /
    
    # Do not enable rewriting for files or directories that exist
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    
    # For requests that aren't actually files or directories, Rewrite to index.php/URL_PATH
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
    
  6. Finally, enter CTRL + Z to append the data to the .htaccess file and hit [ENTER] to save

STEP 2: Configure mod_rewrite in httpd.conf

  1. Locate the httpd.conf file in the Apache sub-directory C:\xampp\apache\conf\httpd.conf

  2. Uncomment the following line from: #LoadModule rewrite_module modules/mod_rewrite.so

    to

    LoadModule rewrite_module modules/mod_rewrite.so

  3. Save the changes to the file

STEP 3: Configure config.php in you site_folder (CodeIgniter) folder

  1. Locate config.php C:\xampp\htdocs\site_folder\system\application\config

  2. Change the following line from: $config['index_page'] = 'index.php';

    to

    $config['index_page'] = '';

Clone this wiki locally