Okay, so I want to apply a domain I bought to one of my websites here. I can not do it directly in panel, only just replace the old domain with new one, and no way to properly setup 301 Redirect to the new domain (when those tho domains are in the same account setting 301 breaks the site to infinite loop)
So my idea now is to copy my website to a new fresh account, and then apply my new purchased domain to it. And in the first, original account I will add my epizy.com domain to 301 redirect.
Using a 301 redirect that leads to a separate domain on the same hosting account works just fine. Source- I do exactly this to redirect visitors of my site’s original free subdomain, to my current custom domain. It makes sense that it works because technically they’re still two separate sites in two different directories. The only two reasons I can think of why this would cause an infinite loop like you describe is if you’re trying to redirect from a custom domain that hasn’t been added to your hosting account, or you added the domain as a parked domain rather than an addon domain.
It would work, but would also be more work than necessary.
I mean I have no other choice. I can not set it up that way in one hosting. If I simple replace the current free domain with the new one, there will be no 301 redirect from the old one, and the previous domain will be deleted.
I specifically need the 301 redirect to be applied from old domain to new one. That’s the important thing. Trust me I already tried multiple ways doing it on the same account, and could not get it done.
I was thinking maybe I can just use .htaccess or even PHP header() redirect, but making a new account seems to be a better bet, then I know it will work 100%.
Just use an .htaccess redirect on the old domain to the new one. Multiple ways you could do this, but setting your 404 error page to your index file, and putting a 301 on the root would be one way. Or you can map every URL on the old domain to the same on the new domain:
On the hosting platform itself, there is no option to “replace” a domain. So instead of deleting your old domain and adding the new domain, just add the new domain and don’t delete the old one.
Migrating the website without downtime is a bit more tricky. The simplest option is to move the website files, but that will result in a few minutes of downtime between moving the website away and setting up the redirect. Copying the files doesn’t have this issue, but there is the risk of data inconsistency if files are being written at the same time.