How to do a page-by-page 301 redirect of a domain to my main domain efficiently?

fatalityhawk

Affiliate Master
Joined
Jul 16, 2020
Messages
47
Likes
25
Degree
0
Does anyone know how can I do a page-by-page 301 redirect of a domain to my main domain efficiently? Both websites are WordPress... Thanks
 
Does anyone know how can I do a page-by-page 301 redirect of a domain to my main domain efficiently? Both websites are WordPress... Thanks

Should be only this in the .htaccess of the redirected domain.
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
</IfModule>

You can tear it all out, database and all, and just have that in the .htaccess and a blank index.html at the root for good measure.

But drop that in the .htaccess first and make sure it works right. I didn't test it. You don't have to take the old version down if you don't want to, in case you ever revert the changes.
 
Should be only this in the .htaccess of the redirected domain.
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
</IfModule>

You can tear it all out, database and all, and just have that in the .htaccess and a blank index.html at the root for good measure.

But drop that in the .htaccess first and make sure it works right. I didn't test it. You don't have to take the old version down if you don't want to, in case you ever revert the changes.
Just want to confirm...

Is a modification of this code going to work if I want to do 301 redirects as follows:

olddomain.com > newdomain.com/abc
olddomain.com/def > newdomain.com/def
and so on mapping each page of the old website to a new page
 
@fatalityhawk, I thought you were asking about making every page redirect to the exact same URL on a different domain in one shot. If you want to manually choose the locations of each and every page then you can do something like:
Code:
<IfModule mod_rewrite.c>
RewriteRule ^/def/ https://newdomain.com/def/ [L,R=301]
RewriteRule ^/abc/ https://newdomain.com/abc-123/ [L,R=301]
</IfModule>

Adding more RewriteRules as you go. You don't have to use mod_rewrite.c either, you can go straight for the kill if you aren't grouping rules wit Regex:
Code:
Redirect 301 /old-slug/ https://newdomain.com/new-slug/

And just stack those up one after another, one for each redirect.
 
Back