0

I Have index.php in my website home page and tried to remove it for some SEO purposes as follows but i am unable to do this by using the scripts in my htacess

<IfModule mod_rewrite.c>

    RewriteEngine On

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

</IfModule>

how i can do this to remove the index.php

Meloman
  • 3,558
  • 3
  • 41
  • 51
Zoo
  • 111
  • 1
  • 9
  • 1
    Try robots.txt file, as an alternate of .htaccess for SEO, you can use **no index, no follow**. – Nirav Madariya Aug 31 '17 at 07:10
  • any way doing this through HTACCESS? – Zoo Aug 31 '17 at 07:11
  • The htaccess will make your website work without having to put the index.php but will not prevent robots of going to it. Try adding a redirect if you'd like, maybe a sitemap or robot.txt? But your htaccess seems fine... – Salketer Aug 31 '17 at 07:13
  • In the same time, you can remove index.php from all your URI, because `/?var=value` is the same as `/index.php/?var=value` ! it's enough to use `...` ! – Meloman Aug 31 '17 at 07:15
  • 1
    there are hundreds of questions at SO that already answered this – hassan Aug 31 '17 at 07:53
  • "I Have index.php in my website home page" - are you even using a _front controller_ (as everyone is assuming)? Or do you simply have an `index.php` in the URL of your "home page" that you want to remove (as your question states)? – MrWhite Aug 31 '17 at 09:52

1 Answers1

0

This is the basic rule to hide index.php from the URL. Put this in your root .htaccess file. mod_rewrite must be enabled with PHP and this will work for the PHP version higher than 5.2.6.

try this

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