I want to redirect domain.com to www.domain.com.I found may people mentioned about Rewrite Rule as shown below in .htaccess. I could not find .htaccess file in my apache. There is httpd.config file. How to force domain to display www.domain.com?

Options +FollowSymLinks

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

Thank You.

Would greatly appreciate your help/suggestion.

Member Avatar


You could write your own .htaccess file and ftp it to your site.

You just need a text editor. However, in order to ensure that it works properly, save the file as, say htaccess.txt, then via FTP client upload it and rename it to .htaccess on the server itself.

Thank you for your quick reply. In my case, I have direct access to the server and no need FTP client upload. Where should I put the .htaccess file? I tried saving this file inside the root directory, but it didn't work.

It should be in your web root folder, usually htdocs on a regular Apache installation.