htaccess Redirect index.php to Domain root

htaccess Redirect www.domain.com/index.php to www.domain.com

RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.doamin.com/$1 [R=301,L]

Redirect www.domain.com to www.domain.com/index.php

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^$ http://www.domain.com/index.php [L,R=301]

For subdomain use the below code :
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

Leave a Reply

Your email address will not be published. Required fields are marked *