Webhosting – Separate Alias Websites (mlutihosting)

  Web Hosting, htaccess, Settings

If you want to create a separate website for any domain(alias), just create subdirectory in directory www/domains on FTP.

Example: We have webhosting and there is added alias example.com and we want to use alias for different website. In this case, just create directory www/domains/example.com and into this directory upload files of website which will be shown on address http://www.example.com/ (it will work for address http://example.com/ too).

If you are using aliases with separate websites, we strongly recommend removing contain main domain to directory /domains/maindomain.tld/. For example, we have webhosting domain1.cz and there was added next domain domain2.com. Recommended placement of files is follows:

  • www – in this directory just left our file .htaccess
  • www/domains/domain1.cz – here upload contain of main website
  • www/domains/domain2.com – here upload contain of alias website

Also, make sure that domain has set correct A records in DNS (this might be set during adding of alias to webhosting).

Also read:

Different subdomains for different aliases

In directory, domains is possible to create directories for subdomains of aliases. For example, if you create directory www/domains/subdomain.example.com, it will be available in a browser on address http://subdomain.example.com/

How is this different from creating in directory www/subdom/subdomain/? Solution with subdom is applied on all addresses, aliases (all domains(aliases) will have common subdomain subdomain with the same content). But solution with directory domains this subdomain we will create only for single domain(alias) example.com.

  • subdomains in subdom – simple solution for webhosting, which do not use aliases
  • subdomains in domains – better solution when using aliases

.htaccess file

Separate sites for aliases are made by using rules that are in the file .htaccess on FTP.

Following .htaccess file is created on webhosting, there is no need to modify it. To use it, just create the required directory according to the instructions above.

The rules for individual sites of aliases in the file .htaccess are as follows:

RewriteEngine On

# domains (aliases)
RewriteCond %{REQUEST_URI} !^domains/
RewriteCond %{REQUEST_URI} !^/domains/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$
RewriteCond %{DOCUMENT_ROOT}/domains/%2 -d
RewriteRule (.*) domains/%2/$1 [DPI]

# subdomains (with or without www at the beginning)
RewriteCond %{REQUEST_URI} !^subdom/
RewriteCond %{REQUEST_URI} !^/subdom/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/subdom/%2 -d
RewriteRule (.*) subdom/%2/$1 [DPI]

# aliases - properly redirected on missing /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^domains/[^/]+/(.+[^/])$ /$1/ [R]

# subdomains - properly redirected on missing /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^subdom/[^/]+/(.+[^/])$ /$1/ [R]

This code solves also creation of subdomains .

Děkujeme za zpětnou vazbu!