0

I got a request to redirect the current domain for a website to another one. So the basic scenario is:

Site is hosted on domain.com and should stay there, but all the links should be shown as site.domain2.com. The basic URL structure of the site should remain the same but the parent domain needs to be changed.

Basically another site is buying the current one and they want their subdomain to be the new default one.

I don't have ownership of domain2.com and it will reside on another server.

Is this possible to do with just .htaccess or do I have to change all of my template links to reflect this as well.

0

METHOD 1: PERMANENT REDIRECT AND EE CONFIG

This is a two part answer, and probably doesn't address your unique question (about keeping the old domain and having all links redirect to the new domain), but it is the easiest way.

  1. What is the web server you are using? Apache? Nginx? You just need a permanent redirect (code 301) in the config file to redirect all queries from domain.com to site.domain2.com. See your respective web server docs for instructions on that. That should ensure that your SEO remains as all queries will be redirected to the new domain.

  2. The only EE part is the name of the site that you define in Control Panel > Administration > General Configuration. That will update all references in your templates provided you are using the standard EE global variables {site_url} in your templates. List of all EE global variables. If your templates have hard-coded references to domain.com then you will need to update them all.

METHOD 2: DEFINE A NEW GLOBAL VARIABLE

An alternative approach would be to define a new variable in Control Panel > Design > Templates > Global Variables called something like {new_subdomain}. This would have the new subdomain you want links to point to. Then do a find and replace in all your templates for any reference to {site_url} and replace with {new_subdomain}.

Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.