Redirect domain.com to www.domain.com


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » Apache Related Information

Redirect domain.com to www.domain.comLast Modified: Mar 16, 2014, 11:00 pm
If you want to force clients to use www.domain.com, you can redirect them from domain.com to the www version with an .htaccess file.

In your public_html folder, create a file called

.htaccess

and add the code

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


Other versions of the same thing do a negation check to see if the domain is not www.domain.com, but that doesn't work if you have subdomains.. hence the need for the explicit check for the value we don't want.

2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST