Hetzner - DokuWiki

KonsoleH:Domain standardmäßig auf Subdomain www umleiten/en

Redirection of a domain to subdomain www by default

A default redirection without the www. prefix to a domain with www. prefix can be achieved using the mod_rewrite command.

Set up an .htaccess file with the following content in the root directory (Document Root) of the domain. Then replace "ihre-domain.de" with your domain name (do not remove any backslashes in the code!).

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.ihre-domain\.de [NC]
RewriteRule (.*) http://www.ihre-domain.de/$1 [L]

This redirects all enquiries, with or without www., to the default URL www.ihre-domain.de.

If more domains are to refer to this folder, simply attach further "Conditions" directly to the code above:

RewriteCond %{HTTP_HOST} !^www\.weitere-domain\.de [NC]
RewriteRule (.*) http://www.weitere-domain.de/$1 [L]

Redirect addon domains to the main domain

Similarly, addon domains can also be redirected to the main domain, e.g. so that the same URL in the address bar of the browser is always shown. Example:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?addon-domain\.de [NC]
RewriteRule (.*) http://www.haupt-domain.de/$1 [L]

The reverse is also possible. You can also redirect a main domain to an addon domain.

© 2019. Hetzner Online GmbH. Alle Rechte vorbehalten.