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.
Limiting the 'duplicate content' or duplicate content
Assume you have the hosting your-domain.com with Infomaniak and as a synonym domain name you have installed www.synodomain.xyz.
By default, when you type one or the other of the domain names (your-domain.com or synodomain.xyz) in the address bar of your browser, it is the one you typed that 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. Thus, if someone types synodomain.xyz, then it is your-domain.com that will automatically be displayed in the address bar.
A code must be entered in 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 exist yet, you must create it on the server.
Insert the following directives in 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
your-domain.comwith your domain name with the appropriate extension (.com, .fr, .ch, etc.) that you want to see displayed in the visitor's browser address bar. Addwww.before your-domain.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, refer to the automatic redirections to httpS.