If your WordPress site is receiving a lot of 404 errors or you’ve changed page URLs, creating a 301 redirect is crucial for maintaining SEO and improving user experience. You can easily set up redirection using the .htaccess file. This tutorial covers manual redirection using .htaccess and using the Yoast SEO plugin.

Note: Before editing the .htaccess file, it’s recommended to take a backup of the original file. A small error in the code can break your site.

Method 1: Redirect WordPress URL Using .htaccess

Step 1: Log in to cPanel > Open File Manager
Step 2: Navigate to your website root directory and locate the .htaccess file
Step 3: Right-click on .htaccess > click Edit
Step 4: In the popup, confirm by clicking Edit

Navigate to website root directory > Right-click on .htaccess > click Edit

Step 5: Scroll to the bottom of the file and add the following line: Redirect 301 /page-one/ https://www.hextoid.com/page-two/
Step 6: Replace /page-one/ with the /old-404/ URL and replace https://www.hextoid.com/page-two/ with the new URL
Step 7: Click Save Changes

At The End of The htaccess File Type Redirection Code

Method 2: Redirect URL Using Yoast SEO Plugin

Step 1: Go to WordPress Dashboard > Yoast SEO > Tools
Step 2: Click on File Editor

WordPress Dashboard > Yoast SEO > Tools > Click on File Editor

Step 3: In the .htaccess section, scroll down and add: Redirect 301 /page-one/ https://www.hextoid.com/page-two/
Step 4: Replace /page-one/ with the /old-404/ URL and replace https://www.hextoid.com/page-two/ with the new URL
Step 5: Save the file by clicking Save changes to .htaccess.

type-the-redirection-code-save-changes

Wrap Up

That’s how you can easily set up 301 redirects in WordPress using the .htaccess file, either manually via cPanel or through Yoast SEO’s File Editor. This method is effective, especially when you want to avoid installing extra plugins for a simple task.

Similar Posts