Fast2Host Logo

Scripting

How to redirect from domain.com to www.domain.com using .htaccess

How to redirect from domain.com to www.domain.com

Create a .htaccess file in your wwwroot folder (Windows hosting) or your public_html folder (Linux hosting), containing the following, replacing domain.com with your domain name:

 

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



Maintain peace of mind with 24/7 UK based support

Email any time or call 01480 26 00 00 014 80 26 00 00