I’m trying to have the example.com
redirected to example.com/home.html
I have .htaccess
file in cPanel public HTML folder but it doesn’t work
I’m new to this so apologies if it’s completely wrong
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} example.com [NC]
RewriteRule ^[a-zA-Z0-9_/]{0,6}$ home.html [R=301,NC]
2
Answers
you just add this code in the last line in .htaccess
or
It is bad practice to redirect the base URL. Instead you should just rename
home.html
toindex.html
. Then it will powerhttp://example.com/
with no rules needed.Another possibility is to use
in your
.htaccess
which will change the name of the default page. Here is the documentation about what your default file should be named and how to change it if desired: mod_dir – DirectoryIndex Apache HTTP Server Version 2.4You should also change links to your home page from
<a href=home.html>
to<a href=/>
. Then users and search engines will never know the actual file name that powers your home page.