John Davidson

javascript - Redirect urls in all wordpress posts

0 comments
Message:


I have a website in wordpress and I need to redirect specific urls, I think it can be done with the .htaccess or through php code or javascript.
Pay attention:
My site creates listings that are like post as follows:
https://agents.nzschoolinfo.com/school/remuera-intermediate-school/
I need all urls to be redirected like this:
https://nzschoolinfo.com/ko-kr/school/remuera-intermediate-school/


Just to be clear.


My site creates with this url:


https://agents.nzschoolinfo.com/school/EXAMPLE1.


https://agents.nzschoolinfo.com/school/EXAMPLE2.


https://agents.nzschoolinfo.com/school/EXAMPLE3


I need to redirect that to this:


https://nzschoolinfo.com/ko-kr/school/EXAMPLE1.


https://nzschoolinfo.com/ko-kr/school/EXAMPLE2.


https://nzschoolinfo.com/ko-kr/school/EXAMPLE3.


I don't really know why it uses a subdomain to create this. But I need to redirect it to the main domain.
I would appreciate very much who could help me.
Thank you



My Answer:
You can achieve this redirection using JavaScript by adding the following code to your WordPress site:

javascript



You can add this code to the header.php file of your WordPress theme or use a plugin like Insert Headers and Footers to add it to your site. This code will check if the current URL contains "https://agents.nzschoolinfo.com" and if so, it will redirect to the new URL "https://nzschoolinfo.com/ko-kr".

Make sure to test this code thoroughly on a staging site before implementing it on your live site to avoid any unexpected issues.

Rate this post

4 of 5 based on 1845 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us