I am just wondering how many types of URL Redirects there are available. I know about 301 and I know there are HTML and HTTP redirections. Can you please clarify the difference and their usage? thanks
URL redirection means that a single web page content is made available under different url's. Having a complete knowledge of URL redirection is necessary for webmasters and search engine optimizers.
HTTP Redirects:
301 redirect is a permanent redirect and is used when any URL gets changed and moved to a separate location. For example www.example.com is moved to www.example2.com then 301 redirect will help the users to visit www.example2.com even if they open www.example.com.
301 redirects helps in proper passing of the link juice without seriously affecting the search engine positioning of the website.
////////////////////////////////////////////////////
302 redirect (usually it is used for SEO purposes) is a temporary redirect when a web page gets available at a different location for some time but the permanent location remains the same. This type of redirect does not passes link juice and trust to the new but temporary url.
////////////////////////////////////////////////////
303 redirects are "see other" redirects. It tells the search engines that the requested resource exists on a different url. This type of redirect does not passes the link value and should be avoided.
////////////////////////////////////////////////////
304 redirects tells the search engines that the requested resource is not modified. Hence these are known as "Not Modified" redirects.
////////////////////////////////////////////////////
305 redirects tells the agents to locate the resource using a proxy. The location field must be specified that contains the URL of the proxy.
////////////////////////////////////////////////////
307 redirects are temporary in nature and are mostly used by web developers.
There are also HTML Redirects
Meta Refresh: The meta refresh redirects the users to a new page after an interval of predefined refresh time. Meta refresh is not treated well in the eyes of search engines as some of the webmasters use this redirect for cloaking purpose which violates the search engine guidelines.
IFrame: When some other page content is forcefully displayed within an iframe so that it looks that it is present on the original URL, then these type of redirects is known as "Iframe redirects". Most of the search engines considers this as a form of cloaking as may penalize a website.
JavaScript Redirects: JavaScript redirects helps to redirect the users from one location to a different location. Search engines do not follow the JavaScript redirects.
If you want to redirect all non-www requests from your site to the www version, all you need to do is add the following code to your .htaccess file:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This will redirect any requests to http://my-domain.com to http://www.my-domain.com. There are several benefits from doing that:
- It will avoid duplicate content in Google
- It will avoid the possibility of split page rank and/or split link popularity (inbound links).
- It's nicer, and more consistent.
Redirecting www to non-www. If you want to do the opposite, the code is very similar:
RewriteEngine On RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC] RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]