Below I will present how to do a 301 redirect from an address without www. to the address from www. I looked through many forums and blogs on SEO and website positioning and the question was very often asked: is it better to have an address with www at the beginning or without www. This topic raises a lot of controversies, the more that some search engines distinguish between these two addresses.

How to make a 301 redirect to www. or without www

So what can we do? Decide on one solution and be consistent. When deciding whether our domain URL will start with www or not, we must remember to follow the established pattern when linking our website.

But what happens if we do not remember this or if people who link to us spontaneously do not know our preferences? In this case, you should use the .htaccess utility. Its principle of operation is very simple – it “explains” to apache how it should interpret the server settings. Below is a short guide on how to make a 301 redirect for both variants:

If we do not have a .htaccess file created yet, then using the notepad, create a new text document, which we call .htaccess and enter its content:

301 redirection from adres.pl to www.adres.pl

RewriteCond %{HTTP_HOST} ^adres\.pl$ [NC]

RewriteRule ^(.*)$ http://www.adres.pl/$1 [L,R=301]

301 redirection from www.address.pl to address.pl

RewriteCond %{HTTP_HOST} ^www\.adres\.pl$ [NC]

RewriteRule ^(.*)$ http://adres.pl/$1 [L,R=301]

If this is our entire edition, save the file and use an FTP client to put it on / (root) of our WordPress installation. From now on, both address variants are interpreted by all search engines as one location.

Write A Comment