Tag Archives: redirecting web site

Redirecting domains to www with .htaccess file

If you have Linux server on your web site, you can easily redirect your “domain.com” to “www.domain.com” with .htaccess file. Every Linux based servers have .htaccess file. However, because of the “.”, it’s a hidden file. So, you can’t view unless you set your ftp client’s “view” property to “show invisible files”. You can turn on “show invisible files” with most of the ftp clients such as FileZilla, Transmit and etc…Even if you enable “show invisble files”, can’t you see the file? So there is an easy way. Just create by yourself in one of the text edit software such as Textedit or Notpad.

1- Open a blank document file with Notepad or Text Edit.


Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

**change domain.com and www.domain.com with your domain name.

3- Save the file as .htaccess without any extension.

4- Upload the file to your server with your ftp client

that’s all. Now check your browser and it’ll work. If you type onto your browser “http://domain.com”, it will be redirected to “http://www.domain.com”