Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

A client wants to create a 301 to his new site that also happens to require ssl. Here's an example of what he wants:  to to to to

I'm reading up on using .htaccess file but it's not sinking in. Wondering if someone could present an example that would accomplish the above and explain it. Thanks!

share|improve this question
up vote 1 down vote accepted

This should do the trick:

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

and you'll need to repeat for any additional subdomains or edit above regex to match all subdomains by doing$ (no carat at beginning which means "begins with")

On RewriteRule, the ^(.*)$ means everything after domain/host. And with this section$1, the $1 tells the first sub regex match element (the first thing in bracket) to be appeneded after

You can also do it via httpd.conf file.

<VirtualHost *>
  Redirect 301 /
share|improve this answer

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.