1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Force a domain name in the URL displayed by the web browser
This guide explains how to force the display of the web hosting name in the browser's address bar to one of the domain names installed as an alias/synonym or how to display the main domain in the address bar instead of the alias.
Limit the "duplicate content" or duplicate content
Suppose you have the hosting votre-domaine.com
at Infomaniak and that as an alias domain name you have installed www.domainesyno.xyz
.
By default, when you type either of the domain names (votre-domaine.com
or domainesyno.xyz
) in your browser's address bar, the one you typed will be displayed in the address bar.
You therefore have the possibility to force the display of a different address than the one that was typed. So if someone types domainesyno.xyz
, then it is votre-domaine.com
that will automatically appear in the address bar.
A code must be entered into a file called .htaccess
which must be located at the root of your hosting (in the /web
folder of your FTP). If this file does not yet exist, you must create it on the server.
Then insert these directives into the file:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://votre-domaine.com/$1 [R=301,L]
Adjust the code above according to these instructions:
- Replace
votre-domaine.com
with your domain name with the appropriate extension (.com, .fr, .ch, etc.) that you want to display in the browser's address bar for the visitor. Addwww.
before your-domaine.com if necessary. - Replace the second line of the code above with "
RewriteCond %{HTTPS} off
" if a loop error occurs, this means that HTTP/2 is active for this site
Also, familiarize yourself with the automatic redirections to https.