Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a url that looks like this: www.example.com/folder. Now, I was wondering how I can tell Apache to redirect the url to folder.example.com

share|improve this question
    
    
@quanta Okay thanks. But maybe the word I should have used was Redirect –  burntblark Oct 16 '11 at 7:22

1 Answer 1

The simplest solution is to place a single .htaccess file inside your /folder directory:

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^www.example\.com [NC]
  RewriteRule (.*) http://folder.example.com/$1 [R=301,L]

</IfModule>

Please note, that your Apache needs to be configured with mod_rewrite

share|improve this answer

Your Answer

 
discard

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.