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

6
  • 1
    Try robots.txt file, as an alternate of .htaccess for SEO, you can use no index, no follow. Commented Aug 31, 2017 at 7:10
  • any way doing this through HTACCESS? Commented Aug 31, 2017 at 7: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... Commented Aug 31, 2017 at 7: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 <a href="/">...</a> ! Commented Aug 31, 2017 at 7:15
  • 1
    there are hundreds of questions at SO that already answered this Commented Aug 31, 2017 at 7:53

1 Answer 1

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]
Sign up to request clarification or add additional context in comments.

3 Comments

Wordpress uses this. And it works since a long time.
I am working with custom php website it will still work?
I don't see why not - this looks fine to me

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.