Recently purchased domain made the Primary Domain in my shared hosting plan.
Using the redirect option in Cpanel, olddomain.com home page is properly redirecting to newdomain.com home page as it should.
No files were removed or moved at all. Newdomain.com uses all the same WordPress files that olddomain.com did, and everything (including Htaccess, if that helps) is in /public_html.
Olddomain.com is now currently sitting as an ADDOn domain in Cpanel on same hosting plan.
Now how do I set up “one for one” 301 redirects for individual URLs? So olddomain.com/contact-us should redirect to newdomain.com/contact-us for example.
With olddomain.com being an AddOn domain, would it be as easy as adding ReWrite rules to the HTACCESS?
Truly appreciate your time!
2
Answers
All it took was adding a separate .htaccess file in the olddomain ADDON directory containing one-for-one 301 redirects as well as a ReWrite rule for the index.
Yes, you can do it with
.htacess
as suggested by Anthony. I just make it little simpler for you.Solution 1:
You can use this code to redirect the
Old Domain
Name to theNew Domain Name
. (Only domain redirect)Solution 2:
If you want to redirect particular Pages as well use the code below. (Don’t forget to add
RewriteEngine on
at the beginning)You can add multiple redirects to redirect each page like
and so on….
Redirect for the root domain to old-domain.com to new-domain.com can be done using
Solution 3:
You can also add the following code to redirect the domain as well as the pages to the new domain using the following
.htacess
code.Solution 4:
You can also do the same using cPanel.
cPanel
and go to theRedirects
Option underDomains
Check this image for better understanding.
cPanel Redirects Option
301
or302
)/
.Redirects to
www. redirection:
option as per your requirement.You are done. cPanel will write the .htaccess code for you.
Hopefully, this is helpful for you.