Setting permanent 301 redirect via .htaccess

Redirect individual files

To redirect individual files, like to newfile.htm you can use a 301 redirect like this

To redirect one specific file to another domain such as to, you need to add the full URL with the domain name.

Redirect an old domain to a new domain

If you have a new domain and want to preserve the traffic and SEO of the old domain, you can write a domain wide redirect. This will tell the browser and the spiders “Hey, I moved to a new address, please update my address on your address book”.

Force www./naked version of domain to be used

Search engine see and as essentially two separate websites. They recommend you pick one version you’d like search engines to display and using a 301 redirect is a possible option.

This will force all links into the www format.

This will force all links into the naked format.

Redirect all files with certain extension

On some rare cases, you may want to change the extension name for your files into something else. The example below will change the php extensions into an htm extension.



The TechnoJunkie of the group who studied engineering but got stuck with software development. Remember kids, 90% of your problems can be solved by marketing. Solving the other 10% just requires good procrastination skills.

You may also like...

Leave a Reply

%d bloggers like this: