cosiek
cosiek

Reputation: 19

How to make 301 redirect from one website to another where the ending is different?

I have 2 websites:

OLD one - https://www.old.example/en/

NEW one - https://new.example/en

Lastly, Google Search Console reported around 80 improperly redirected links for OLD website, i.e.:

https://www.old.example/en/?p=41310

https://www.old.example/en/?p=45659

https://www.old.example/en/?p=72785

In .htaccess of OLD page is inputted only code:

Redirect 301 / https://new.example/

which redirects above links from OLD page to i.e.

https://new.example/en/?p=62692

How can I correct it and i.e. expect to have in such cases always redirection to main page - https://new.example/en

Upvotes: 0

Views: 182

Answers (1)

MrWhite
MrWhite

Reputation: 45968

To remove the query string completely (without a stray ? at the end) you'll need to use mod_rewrite instead.

For example, in the .htaccess at the old domain:

RewriteEngine On

RewriteRule ^(en)/ https://new.example/$1 [QSD,R=301,L]

Aside: Although this many-to-one redirect will likely be seen as a soft-404 by Google.

Upvotes: 1

Related Questions