Redirection code required

Hello @kerimsarigul,

I need a redirection code. Here are various scenarios.

Case-1) Earlier we have journal with URL https://journals.domain1.com/journal1/ (without index.php)

Later we have moved it to new domain.

Case-2) URL: https://journal.domain2.com/index.php/journal1/ (With index.php, Note: journals to journal)

We have published few articles with this URL.

Later we have removed index.php from URL in Case-2. We have published few articles using this URL.

Case-3) Now, with domain remaining same (domain2), we have changed the URL to https://journals.domain2.com/index.php/journal1/ (Note: Journal to Journals)

Now, we are facing google search console duplicate content issues.

Can you please help with the permanent redirection code, where any earlier URLs to permanently redirect to the URL in Case-3 above.

Thank you in advance.

If I understand the terms journal and journals correctly, the following codes should work.

RewriteEngine On

# Case 1: Redirect from journals.domain1.com/journal1/ to journals.domain2.com/index.php/journal1/

RewriteCond %{HTTP_HOST} ^journals\.domain1\.com$ [NC]
RewriteRule ^journal1/ https://journals.domain2.com/index.php/journal1/ [R=301,L]

# Case 2: Redirect from journal.domain2.com/index.php/journal1/ to journals.domain2.com/index.php/journal1/

RewriteCond %{HTTP_HOST} ^journal\.domain2\.com$ [NC]
RewriteRule ^index\.php/journal1/ https://journals.domain2.com/index.php/journal1/ [R=301,L]

# Case 3: No need for redirection as it's already the desired URL.

# Additional: Redirect from journals.domain1.com to journals.domain2.com

RewriteCond %{HTTP_HOST} ^journals\.domain1\.com$ [NC]
RewriteRule ^(.*)$ https://journals.domain2.com/$1 [R=301,L]

# Additional: Redirect from journal.domain2.com to journals.domain2.com

RewriteCond %{HTTP_HOST} ^journal\.domain2\.com$ [NC]
RewriteRule ^(.*)$ https://journals.domain2.com/$1 [R=301,L]

@kerimsarigul Thank you for the code.

Should I use the entire code in the .htaccess of the existing domain.

Yes.
According to the scenario mentioned above, both domains (journals.domain1.com and journals.domain2.com ) should point to the same website.

Make sure to place this code in the .htaccess file in the root directory of your website on the journals.domain2.com server.

@kerimsarigul

I have tried the code. May be I have gone wrong somewhere.

I just want to give better explanation. Kindly consider.

https://journals.ABC.com/ijepes/ moved to https://journal.PQR.com/index.php/ijepes/ moved to https://journal.PQR.com/ijepes/ moved to https://journals.PQR.com/index.php/ijepes/

Now I need, all the old URLs should permanently redirected to https://journals.PQR.com/index.php/ijepes/

Thank you

@kerimsarigul

I have tried the code. May be I have gone wrong somewhere.

Here is the scenario. Kindly support with the code

https://journals.ABC.com/ijepes/ moved to https://journal.PQR.com/index.php/ijepes/ moved to https://journal.PQR.com/ijepes/ moved to https://journals.PQR.com/index.php/ijepes/

Now I need, all the old URLs should permanently redirected to https://journals.PQR.com/index.php/ijepes/

Thank you

Didn’t this scenario work?

@kerimsarigul

I have tried. But google search console is still showing duplicate content issue.

Can you please go through the scenario below and help with the code again.

https://journals.ABC.com/ijepes/ moved to https://journal.PQR.com/index.php/ijepes/ moved to https://journal.PQR.com/ijepes/ moved to https://journals.PQR.com/index.php/ijepes/

Now I need, all the old URLs should permanently redirected to https://journals.PQR.com/index.php/ijepes/

@kerimsarigul

I have tried. But google search console is still showing duplicate content issue.

Can you please go through the scenario below and help with the code again.

https://journals.ABC.com/ijepes/ moved to https://journal.PQR.com/index.php/ijepes/ moved to https://journal.PQR.com/ijepes/ moved to https://journals.PQR.com/index.php/ijepes/

Now I need, all the old URLs should permanently redirected to https://journals.PQR.com/index.php/ijepes/

Google Search Console Updates Are Not Immediate:
It’s important to note that Google Search Console does not provide real-time updates. Changes made to your website, such as submitting a sitemap or requesting indexing, may not reflect immediately. Google’s algorithms need some time to process and index the modifications you’ve made. Be patient and allow Google the necessary time to update its search results.

URL Removal via Google Search Console:
If you need to remove specific URLs from Google’s search results, you can use Google Search Console to request their removal. This tool provides you with the ability to temporarily hide or remove URLs from the search index, but it’s important to understand that this doesn’t guarantee the immediate deletion of content from the web; it merely influences what Google displays in its search results.

1 Like