Remove www and index from domain

Error Message


Other Information

I’m getting a 404 error message when I just try and type
I have to type www and /index to load the site. How do I load the site without the www and hide the file name extension. I’ve tried this with htaccess but can’t get it work properly.


hmm, you’re using CloudFlare. You can add CNAME for your main domain as described here:


What do I need to put for Target?

8 random-character main domain. You can find it in client area


Sorry I’m a bit confused, the client area where?


At Login to your account - InfinityFree, select the website you mentioned here, and under Account Details, there is a section that says ‘Main Domain’. It will look something like this:

In the Cloudflare DNS Section, click add a new record, change the type to CNAME, put the host as @ and the target as the domain found in the Client Area.

If you want to remove file extentions, add this to your .htaccess code:

Options -Indexes +MultiViews +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\index [NC]
RewriteRule ^ %1 [R,L,NC]

and if you want to remove www

remove www

RewriteEngine on
RewriteCond %{HTTP_HOST} ^ [NC]

RewriteRule ^(.*)$$1 [L,R=301]
change the http:// bit to https:// if you have ssl


Thank you for you help everyone. I’ve done all of the above but 'm now getting an error that says:

This site can’t provide a secure connection sent an invalid response.


I also have this CNAME flattening thing (see screenshot) does that matter?Screen Shot 2021-02-11 at 10.55.34

And I’m still getting a 404 error, argh!!

Screenshot CF dns entry

Press on the grey cloud to make it orange cloud for both CNAMES


for a certificate you have to be inside the orange cloud

And why do you still have 404

the problem is in your .htaccess
which undoes the default .htaccess
which seeks to serve index.html as the home page

You delete the extension and it can’t find that file



FlutterHoney said it needed to be grey?

What code do I need to remove the index.html from typing it in and just using I tried the code above but it’s not working

This is my htaccess file

1 Like
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]

I still get a 404