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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following rewrite rule setup:

rewritecond %{http_host} ^ [nc]
rewriterule ^(.*)$$1 [r=301,nc]

Now this works for redirecting to however it won't redirect any folders e.g. won't redirect to

share|improve this question
up vote 1 down vote accepted

First advice: use proper lower/uppercase:

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

Then maybe you forgot the "L" for "Last rule".

When you say "it won't redirect any folders e.g. won't redirect to" please explain what it gives, what it should give, and what it give without the rewrite rules. Then I could help you further.

Two hints:

Please try to use the RewriteLog directive: it helps you to track down such problems:

# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On

My favorite tool to check for regexp: (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)

share|improve this answer
Another useful tip is to use curl -I or curl --include to test your rules. Doing this in a browser can result in several redirects happening with no hint that this is going on, leading to much confusion. – Ladadadada Dec 8 '11 at 7:53
When I try view it just does nothing, no redirect over to, it just loads redirects to though. – Luke Dec 9 '11 at 2:22
Looks like I had another .htaccess that was interfering with some folders. Thanks again for all your help. – Luke Dec 12 '11 at 12:52

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.