Connect second domain to web site

Started by RanKumar, Nov 17, 2022, 10:05 AM

Previous topic - Next topic

RanKumarTopic starter

Good day!
How to attach a second domain to an Open Cart site?
At the domain, registered hosting DNS . On the hosting in ISPmanager, I registered a new domain with an alias.
It works! But! Only the main page. If I follow the links on the site, the domain changes back to the old one.
What to do?
  •  

tvalexndar

And the fact that this will lead to possible changes in search results, since they will perceive it as duplication of content, does not worry you? If not, then you need to look into the web server settings, in particular, what is configured in VirtualHosts and .htaccess. Watch ReWrite_cond. An alias is an alias to redirect to the main one.

You can make a substitution, when entering domen-1, switching to domen-2 is easier. In the main directory on the hosting there is .htaccess enter the following there:

# HTTP Rule
RewriteCond %{HTTP_HOST} ^www.domen-1\.com
RewriteRule ^(.*)$ http://domen-2/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.domen-2\.com
RewriteRule ^(.*)$ http://domen-2/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domen-1\.com
RewriteRule ^(.*)$ http://domen-2.com/$1 [R=301,L]

In my example, different visits from www are taken into account. or without, https addresses are especially sensitive (if there is ssl)
  •