WordPress index.html redirect to root

Written by | Posted on March 21st, 2018

After I finished and configuring my HTML/CSS template for WordPress theme I suddenly figure it out on my google webmaster tools and google analytics that I have a multiple duplicates link to my WordPress Blog web site.

I found that every page of my website had index.html that turn into Page Not Found Error 404, it was a bad impression to SEO and the big factor to declined my search engine google traffic.

Redirect your URL pages can be done by your server-side scripts like PHP or any kind of web programming script but editing .htaccess is the easy way to do redirect all of your pages without touching your PHP code in WordPress.

Things to do you need to access your website control panel or Cpanel, access your directory root using FTP file transfer protocol or directly edit it on your Cpanel.

Cpanel File Manager

Navigate your WordPress website root directory files where you can find the “public_html” folder open it and find the .htaccess and click edit.

NOTE: Some of the Cpanel web server’s are default hiding the .htaccess file.

In order to view the Cpanel hidden files, click the settings on the top right side.

Cpanel-Settings

Check the Show Hidden Files (dotfiles) and save it.

Now you can see the .htaccess edit that file and put the code something like this at the top of your .htaccess

It looks like this

.htaccess Edit

NOTE: It didn’t work if you place the code above or in the middle in order to read it primarily put or place it at the top.

After you save it try to test some link pages in your browser, for example, “www.example.com/index.html” it will redirect to your main page URL “www.example.com” same to all of your pages.

This can till google crawler that all index.html link in your pages will redirect to the root page. Wait for a week to recrawl the google bot spider all your pages to index them in the search engine.

Happy blogging 🙂