-1

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

burntblark
  • 101
  • 2

1 Answers1

3

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

mate64
  • 1,681
  • 4
  • 18
  • 29