Most common .htaccess rules

Home > Programming & Technology

3 simple steps to remove index.php from CodeIgniter so that you can have clean URLs.


Step 1 -  Open the file config.php located in application/config path.  Find and Replace the below code in config.php  file.


//  Find the below code

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

//  Remove index.php

$config['index_page'] = ""


Step 2 -  Write below code in .htaccess file

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


Step 3 -


<Directory "/var/www/html">
   AllowOverride All


Caching static Assets


# 15 Days for most static assets

<filesMatch ".(css|jpg|jpeg|png|gif|js|ico|svg)$">

Header set Cache-Control "max-age=1296000, public"



Redirect HTTP to HTTPS

#After FollowSymLinks and Engine On

Options +FollowSymLinks

RewriteEngine On



# Rewrite to https:// protocol

       RewriteCond %{HTTP:X-Forwarded-Proto} !https

      RewriteCond %{HTTPS} off

       RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


Remove WWW from your domain

#Remove WWW

       RewriteEngine on

       RewriteCond %{HTTP_HOST} ^www\.

       RewriteRule ^(.*)$$1 [R=301,L]


Redirect an entire directory to homepage

Sometimes it happens that you may have created a set of pages in a directory which are not relevant anymore and you want them removed from your website.


The best way is to Redirect 301 them to your homepage so any “link juice” is transferred to your Domain without being lost, plus you don't get errors of 404.


RewriteRule ^folder_name/(.*)$ [R=301,NC,L]


For example,  ->


To keep the URI and append it to the redirected path

For example,  ->


RewriteRule ^folder_name/(.*)$ /$1 [R=301,NC,L]


Comment Form is loading comments...

Table of contents

Most common .htaccess rules

Remove index.php from domain, Setting up caching using.htaccess file, Redirect HTTP to HTTPS, Redirect the entire directory to Homepage using .htaccess

How does Siri suggest contacts

Is Siri suggesting you to call your ex-boyfriend, ex-husband or your crush?How does Siri suggests contacts to Call or Whatsapp?Siri has access to your Whatsapp data, which includes your Data and Storage Usage. Siri is very likely using this data to understand your texting pattern.

[Solved] You do not have permission to save in this location - MacOs

Before you read the solution to this error, if you are using QuickTime Player to export a file and this issue is coming, just keep the video window open and you won't get this error.

6 Simple steps to Install SSL Certificate

Regardless of the kind of server you use (Apache HTTP Server, Tomcat or IIS), this simple guide to SSL Certificate installation will give you the overall idea of how the SSL Certificate is issued and installed and will help you in understanding the steps and troubleshoot the problems that you may be

[Fixed] schema is deprecated

You are referring to a (which is now deprecated) for your SD, and not You need to use the JSON-LD structure Data format in order to get rid of this error. First, you need to visit website and scroll down to find the data format tab with JSON-LD struc