Score:0

301 redirect for some pages and all other pages

gb flag

I have two websites. Let's say siteA.com and siteB.com. Now I want to add 301 redirect to siteB.com. Some of pages of siteB.com need to be redirected to some specific pages on siteA.com All other pages of siteB.com neet to redirect to the home page of siteA.com including siteB's home page. My final requirement is no one can access siteB after adding the redirection. These are two wordpress sites. How can acomplish this with htaccess file or a wordpress plugin?

kz flag
Do `siteA.com` and `siteB.com` point to different vHosts/servers?
ashanrupasinghe avatar
gb flag
Yes. Different.
Score:1
kz flag

Since siteA.com and siteB.com point to different vHosts/servers then you can remove all the existing directives in siteB.com/.htaccess and use the simpler mod_alias Redirect and RedirectMatch directives.

For example:

# siteB.com/.htaccess

# Specific redirects
Redirect 301 /foo https://siteA.com/another-foo
Redirect 301 /bar https://siteA.com/another-bar
Redirect 301 /baz https://siteA.com/another-baz

# Redirect everything else to homepage on siteA.com
RedirectMatch 301 ^ https://siteA.com/

Test first with 302 (temporary) redirects to avoid potential caching issues.

NB: Redirecting everything else to the homepage on the other site will likely be seen as a soft-404 by search engines and isn't particularly helpful for users. It is often preferable to serve a more descriptive 404 instead.

My final requirement is no one can access siteB after adding the redirection.

Since everything is redirected, siteB.com is effectively inaccessible.

Reference:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.