Remove index.php from URL to avoid duplicate content issue

You want to redirect to ? Are you tired of finding proper solution about how to Remove index.php from URL to avoid duplicate content issue  or to redirect index.php to actual URL without index.php? You are in the right place mate!

I am a PHP based developer and most of time I use CodeIgniter as my php framework. Those who use CodeIgniter and obviously other framework, we use some technique to remove index.php  from our URL to make it more clean, short , Web 2.0 friendly and penitentially to avoid duplicate content issue in Google Web Master. In CodeIgniter, we do it in two steps:

How to remove index.php from URL in CodeIgniter

Step 1: We update application/config/config.php file

//keep the variable empty to remove index.php after your domain name
$config['index_page'] = '';

Step 2: We update our .htaccess file as

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

Cool! That removes index.php from our URL.. thats really great… but wait! What if anyone put index.php in your url like ? Yes that is still accessible and duplicate content of .

How I removed the index.php from url

I had the same problem in one of my project and needed to solve it. I spend hours to solve it but couldn’t found any solution until I found this post htaccess remove index.php from url in stackoverflow. I just put following lines in my .htaccess file

RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

and my problem solved.

Now if you intentionally write in your address bar, it will be converted to . I guess your problem is solved to.

Let me know if it helps you