If you want to configure internal ("hidden") redirection to multiple directories for multiple domain names on your Linux account, this can be done if the following conditions are met:

  • You have a few domain names, for example: domain1.com, domain2.com, and domain3.com
  • You want to point them to /htdocs/dir1, /htdocs/dir2, and /htdocs/dir3 sub-directories accordingly
  • And you want to see www.domain1.com in the address bar (instead of www.domain1.com/dir1) when redirection is done

In order to setup this type of redirection:

    1. Add the following lines to your .htaccess document in your root directory (/htdocs).
      Note: Change domain1.com, domain2.com, and domain3.com to your actual domain names, and change dir1, dir2, and dir3 to your actual sub-directories where domain names should be redirected.

      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^(www.domain1.com|domain1.com)$
      RewriteRule ^(.*)$ /dir1/$1 [L]
      RewriteCond %{HTTP_HOST} ^(www.domain2.com|domain2.com)$
      RewriteRule ^(.*)$ /dir2/$1 [L]
      RewriteCond %{HTTP_HOST} ^(www.domain3.com|domain3.com)$
      RewriteRule ^(.*)$ /dir3/$1 [L]

    2. Add the following line to all .htaccess files in specified sub-directories (/htdocs/dir1, /htdocs/dir2, /htdocs/dir3) where domain names should be redirected.

      RewriteEngine Off

Note: This solution may not work correctly if you are already using mod_rewrite (if you use the RewriteEngine On directive in any other .htaccess files on your account).

For more details on various .htaccess file usage, read Apache HTTP Server Tutorial on .htaccess files.

In case you can not find .htaccess file in your account folder (after it had been uploaded), you may need to make use of the FTP client that supports an option to show hidden system files, e.g. FileZilla.