What is .htaccess 301 redirect
What Is A .htaccess File?
According to Wikipedia, a .htaccess file is "the default name of a directory-level configuration file that allows for decentralized management of web server configuration." If you're not a computer whiz (and I'm not), such a definition is simply impossible to understand. So putting aside all the computer programming terminology, a .htaccess file is a small file which is placed within a website to perform a number of functions.
In this article, we will talk about 2 of these functions (there are many others) because they are the only ones related to SEO. I will also show you how to write the .htaccess file so that you use your .htaccess file for maximum SEO effect.
1) Blocking Users
A .htaccess file can be used to allow and block users by domain or IP address. The reason why you would want to do such a thing is because there are many online tools which people use to grab their competitor's keywords. This will then allow them to target your keywords and potentially push you down the search rankings. For example, one such tool is SpyFu. They literally allow you to spy on your competitors. If you want stop such tools from being used on your website by your competitors, then simply structure your .htaccess file like the example at the bottom of this article.
2) Redirecting URLs
a) Use a 301 redirect to move a site from
http://www.oldurl.com/uncool/ (root of the old homepage)
to http://www.newurl.com/cool/
Create a .htaccess file in your root directory. If one already exists then you can just add this line of code to it.
Redirect permanent / http://www.newurl.com/cool/
301 redirects are used to permanently move a site to a new location. Search engines do not apply penalties to 301 redirects the way they apply them to many other types of redirects.
When you create a .htaccess file make sure you transfer it in ASCII and not binary. You will probably want to CHMOD the file to 644 for security reasons as well. .htaccess is an Apache technology and not a windows server technology.
b) Also If you did a search on Google and looked through the search results, you will find that some websites are indexed with http://www. in front of them and others without it. If you searched a bit deeper, you will probably find some websites indexed twice, once with the http://www. in front of them and others without it.
Why is this the case?
This is due to backlinks being built to both the http://www. and the non-www. but the search engine treats them as separate websites. This means that you are creating links to 2 separate websites instead of just one. As a result, any SEO benefit is getting divided up between 2 websites when they could helping just one and getting much better results. In order to avoid such a problem, you have to redirect one URL to the other. It is best to redirect the URL with the least amount of backlinks to the one with the most amount of backlinks.
.htaccess File Example
Below is the .htaccess file I use for the great majority of my websites. It blocks access to the biggest and well-known spying tools on the Web as well as redirects a non-www. URL to a http://www. URL. Modify the code slightly by replacing "yourdomain" with your URL.
Simply copy the code, paste it in a notepad file and then save it as .htaccess. Then upload it using ftp or other means to your website.
Options +FollowSymLinks RewriteEngine on order allow,deny deny from all
order allow,deny deny from 74.53.36.242 deny from 65.39.72.142 deny from 66.34.204.26 deny from 66.34.0. deny from 66.34.255. deny from keycompete.com deny from keywordspy.com deny from keywordspypro.com deny from spyfu.com deny from spyfoo.com deny from foospy.com deny from fuspy.com allow from all
RewriteCond %{HTTP_REFERER} keycompete.com [NC,OR] RewriteCond %{HTTP_REFERER} keywordspy.com [NC,OR] RewriteCond %{HTTP_REFERER} keywordspypro.com RewriteCond %{HTTP_REFERER} spyfu.com [NC,OR] RewriteCond %{HTTP_REFERER} foospy.com [NC,OR] RewriteCond %{HTTP_REFERER} fuspy.com [NC,OR] RewriteCond %{HTTP_REFERER} spyfoo.com [NC,OR] RewriteRule .* =96 [F] RewriteEngine on RewriteCond %{HTTP_HOST} ^([a-z.]+)?yourdomain.com$ [NC] RewriteCond %{HTTP_HOST} !^www. [NC] RewriteRule .? http://www.yourdomain.com%{REQUEST_URI} [R=3D301,L]
source: seoconsultantsydney.com.au
0 comments:
Post a Comment