I’m changing a company name and need to switch from domain1.com to domain2.com. All of the URLs on domain1 have a corresponding URL on domain2. Both domains are on cPanel hosting.
I do not want to forward other subdomains. The MX records for email are handled by a different server and should not forward. It may be worth noting that the .htaccess file is used to force www (ie domain1.com/faqs forwards to www.domain2.com/faqs) and that DNS management is handled through the Cloudflare CDN service.
What would be the best way to set-up the forwarding? I’d prefer to eventually close the domain1 cPanel account, but I also do not mind keeping it since it costs me nothing to do so.
Thanks for the link. Unfortunately they made a mistake and repeated the solution for the first condition, which is “redirect all files from old domain to root of new domain”.
I did more searching and came up with this excellent solution. It has both a www and non-www example. Since the new site also redirects non-www to www, I was able to use the www version of the code on the old site.
I actually had the parentathese in there originally and was told by someone I believed (don’t remember) that they were not nessesarry if I was only doing yada yada
In the first two examples on your site, the parentheses are indeed not necessary, because you’re not using any captured value in the replacement. But in your third example, the replacement uses $1, which will be blank unless you use parentheses to capture the path.