Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've looked through the other posts here and haven't been able to solve this yet. I'm trying to redirect my to using the .htaccess folder found in my root directory.

I've tried the examples listed here and elsewhere. rewriteengine is on.

rewriteCond %{HTTP_HOST} ^www.(.) [NC] rewriteRule (.) //%1/$1 [L,R=301]

I've plugged this in in different spots of my .htaccess file, and I get redirect errors, saying it's improperly redirected.

In the above example, do I need to plug my actual site information in somewhere? If so, can someone give me an example using

I'm on a Linux based server, through Godaddy. Thanks!

share|improve this question

migrated from Oct 4 '10 at 13:45

This question came from our site for professional and enthusiast programmers.

2 Answers 2

RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1
share|improve this answer
Joni, thanks. I entered in your code after inputting my domain info and I got a 500 Internal Server Error, however I noticed it was an Apache server. Any ideas? – Geo Jul 25 '10 at 17:39
Can you see error logs? I don't know how to see them trough Godaddy. – Joni Jul 25 '10 at 19:24
Got anything that also shows http/https depending on how they came in? – ServerChecker Apr 27 '12 at 1:19

You presently have

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

I think you're almost there. Remember that in a regular expression a single dot . matches a single character. If you want to match one-or-more characters then try .+. And if you want to match zero-or-more characters then use .*. E.g.:

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

(you also need the leading http: for the redirect URL).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.