Mini Howto: 301 redirect using htaccess & apache

How to redirect index.php to index.html, correctly and friendly with the search engines so you don’t lose traffic?

Well, a 404 is not the way!

The 301 redirect is easy.  Edit your htaccess file on your linux server in the root directory of your site, or create one if you do not currently have one.

My old page was index.php and I wanted it as index.html, I have my index.html uploaded to my site.

The simple contents below is all that you need:

redirect 301 /index.php https://www.m3server.com/

The above line will redirect  your index.php requests to your main web site url, in this example.

Perhaps you had a page that you want to change its name to.  Rename the file to the name you wish to use, add the redirect, presto – your traffic saved and served without a nasty 404.  Example is below:

redirect 301 /fishin.html https://www.m3server.com/fishing.html

That is a fictitious link, but you get the idea.

If you make a mistake and your web site appears broken, first step should always be to rename your .htaccess file to off.htaccess, see if that resolved your trouble.  If it does, then you just need to isolate the bug in your .htaccess file.

M3Server.com – world.class.hosting