How to redirect website.com/and website.com/index.php to another page using htaccess
I can redirect website.com/index.php
to website.com/home
, but I cannot find a way to redirect website.com
towebsite.com/home
I tried RewriteRule ^/$ /home [R=301]
it but it doesn't do anything.
+3
b4r
source
to share
2 answers
try it
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC]
RewriteRule .* http://www.website.com/home [R=301,L]
This rule redirects www.website.com to www.website.com/home
Or add this to your .htaccess
RewriteRule ^/?$ /home [R=301,L]
+1
starkeen
source
to share
One rule can handle both redirects:
RewriteRule ^/?(index\.php)?$ /home [NC,L,R=301]
+1
anubhava
source
to share