How to force domain url to display


I want to redirect to 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

Options +FollowSymLinks

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

Thank You.

Would greatly appreciate your help/suggestion.

The .htaccess file goes in the root directory of the host. The code you have there will work, you just have to upload it to the root directory of the domain you want it to work on.


Pardon my going off on you but did you bother to read the sticky threads or any of the other threads before posting your question?

My signature’s tutorial was developed years ago in a vain attempt to avoid carpal tunnel syndrome yet it has CODE to force www or force the elimination off www from the domain. There is an abundance of other information there, too, from setting up a test server, testing it, creating efficient mod_rewrite code and providing a large number of examples (with full explanations).

That tutorial was posted by SitePoint (with extensive modification) as an article AND I’d created sticky posts with the same info. If you can’t find any of that, …

Go have a look … but come back with questions (if you have any after reading the tutorial). I’ve been here for years to help people learn and there are others in here who understand mod_rewrite, too.