It occurred to me that just maybe you don’t want to display your site with the www subdomain prefix. In that case you could deploy the following code in your .htaccess file to redirect www to non-www. By doing so, users will access your site at http://domain.com not http://www.domain.com.

.htaccess

If your website is hosted on an apache server, a redirect from www to non-www is a simple implementation. Add the following to your .htaccess file

[php toolbar=”true” classname=”one_line”] RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L] [/php]

Add the above code to you .htaccess file and replace domain.com with your domain name.

Leave A Comment