Redirect index.php to root in .htaccess
Redirecting from index.php to the root of website. That is, from domain.tld/index.php to domain.tld/. Directives for .htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
Commentary
Enable runtime rewriting engine:
RewriteEngine On
If full HTTP request line sent by browser contains "index.php":
RewriteCond %{THE_REQUEST} ^.*/index\.php
Then redirect from domain.tld/index.php to domain.tld/:
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
Notes
- Apache Module mod_rewrite docs: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Web servers
- Apache + nginx