Here is a quick and easy code you can use in your .htaccess file, located in the root directory of your website, to remove any world-wide web letters from your url. This will remove “www” from all your website’s pages as well as search engines, etc.
[code lang=”apache”]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$ [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R=301,L]
[/code]
And vice-versa you can add “www” to your website’s url with the following .htaccess code:
[code lang=”apache”]
RewriteEngine on
Options FollowSymlinks
Rewritecond %{HTTP_HOST} ^mywebsite.com [NC]
Rewriterule ^(.*)$ http://www.mywebsite.com/$1 [R=301,NC]
[/code]
All I did here was switch the places of the url of with “www” and the url without “www” in the code.
Just replace “mywebsite.com” with your website’s domain name.