
When it comes to building a website there are many important factors which need to be taken into consideration, some of which are often overlooked. One example of these is your sites URL. We’re not talking about the domain you choose to host your site on or what your site is called but more to do with the www part of your sites URL.
One Web, One Format: The Case for Forcing ‘www’
In this quick tutorial we’ll show you how to force it so that your website URL is always using www. Doing this means that the non-www version of your URL needs to be redirected to the www version. Doing this forced redirection is a very easy task and doesn’t take long at all.
Redirect with Purpose: Forcing ‘www’ for Better Consistency
All you need is to copy and paste the following code snippet into a file called .htaccess placed at the root of your website. If this file does not already exist, create it. If however you already have a .htaccess file in place you should copy and paste the following code and place it at the top of your .htaccess file.
1
2
3
|
RewriteEngine On RewriteCond %{HTTP_HOST} ^news-and-reviews.co.uk$ [NC] RewriteRule ^(.*)$ https://news-and-reviews.co.uk/$1 [R=301,L] |
In the code above you will of course need to replace webdevelopmentblog.net with your own sites domain name.
The opposite of this would be to forcefully remove the www which then makes the URL slightly shorter. It is of course your choice but the important thing is this: once you have picked which style you would prefer to use try to stick to it.