How to 301 redirect www to root?

I can’t beleive how painfully difficult it is to find a simple 2-liner answer to a simple question:

I need to redirect requests that come to to

I am sure there is a simple 1-3 lines of code in httpd.conf that can do that. Instead when Googling for the answer, I keep seeing a long essays about 301 redirects but no real-world workable solution!
It’s like everyone wants to write a long article about it, probably for seo purposes but nobody wants to just say, here, this is how you do it:… done!

Can someone please just tell me the what to add to httpd.conf

my new site is

I don’t want people to use the www part, so all traffic should be redirected to the

Thank you.

The setting to do that redirection should be found in your Host Control Panel.

I am with DreamHost so I got the option. Check to see if you got it too.

This starting to be funny. All lectures but no real answers. What If I don’t have a control panel? Then what?

I tried this one
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

but then when someone what typing
it was redirecting to
It was adding an extra / at the end
and when typing
it was redirecting to
another extra slash.

I just changed that rule to
RewriteRule ^(.*)$$1 [R=301,L]

So now it seems to be working.


Did you bother to look at the sticky threads? Did you bother to look at the tutorial linked in my signature? The code is there! Sorry, I get SO frustrated at the lack of “minimal effort” by posters asking simple questions.

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

WILL, as you discovered, redirect to While

WILL give you the answer you want (on Apache 2.x), it’s still not (universally) correct.

RewriteCond %{HTTP_HOST} ^www\\.god\\.tw$ [NC]
RewriteRule .?{REQUEST_URI} [R=301,L]

WILL take care of the problem MOST EFFICIENTLY on either version of Apache.