How to redirect the address without www to www and the other side


301 redirect is one of the most important principles of optimizing the site for search engines..

Unfortunately, only some people, launching his first blog or website realizes how important it is to exist only at the ONE address..

Many sites in the network operates at two addresses:

  1. www.domain.com
  2. domain.com

By default, when you start with new service, it works on both addresses and all search engines, including Google – the most important they see your service as two separate sites!

Wht worse can happen… we could be banned by Google and our website will not be visible or will be very far in search results because this will be treated as duplicate content on the Web – the so-called. “Duplicate content”.

To avoid this, simply add 301 redirect in .htaccess file, it’s a permanent redirect.
The file is located in the main domain directory – public_html, if it doesn’t, create a text file with the same name.

For a 301 redirect from the address “without www” to “with www”:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^arkades.pl(.*) [NC]
RewriteRule ^(.*)$ http://www.arkades.pl/$1 [R=301,L]

For 301 redirect from the address “with www” address to “without www”:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.arkades.pl(.*) [NC]
RewriteRule ^(.*)$ http://arkades.pl/$1 [R=301,L]

Use a 301 redirect also when you change service address to another.
In this case you should add new address of your domain in .htaccess file:

RewriteEngine On
RewriteRule ^(.*)$ http://www.newaddress.com/$1 [R=301,L]

Which is better to use – the address with or without www?

This question has no clear answer, it’s a little matter of taste;)
The main thing is to use redirection and point to a single address.

Personally, I use for all my domains addresses with www, but without www might make sense if our address is very long – it just does not make sense to prolong it even more on www.