DED9

How to fix WordPress 404 error after changing a unique link in WordPress

WordPress 404 error is a major problem when changing a unique link in WordPress for any site. Imagine that you have installed WordPress, and after some time, you have uploaded your site, you are still using the default structure for the single link of your site. Still, while you are working on your site, suddenly you see an SEO article in which It has been said that for the structure of the unique WordPress link on your site to be optimized for search engines, try to use the structure that includes the name of the post.

So you make your own decision and change your unique link, but what happens after this incident is that all the pages of your site will get a 404 error, and you need to transfer the users to the correct address of the content to cause a drop in the site’s ranking. Do not redirect users to a page without content. Therefore, in this tutorial, I will fix the 404 error after changing the WordPress unique link; stay with us until the end.

If you encounter a WordPress 404 error when changing a unique link and you do not use the WordPress SEO plugin to redirect to a new structure, return your unique link structure to the previous state and then follow the steps mentioned in the second method of this article to redirect users to Do the new WordPress unique link structure.

Fix 404 error after changing WordPress unique link

In order to solve the problem of 404 error after changing unique links in WordPress, there will be two solutions in front of you, which are:

  1. Using the WordPress SEO plugin and using the redirect feature to a new unique link
  2. Change in htaccess file. and redirect users to the new unique link structure

Using the WordPress SEO plugin

If you use the WordPress SEO plugin or Yoast Seo, it will be easier for you, and you will not need to make any changes and make special settings in order to be able to direct users to the new structure of the unique link. If you use the WordPress SEO plugin, this plugin will be able to direct the users who were directed to the old unique link or the same old link of the site content as a 301 redirect to the new unique link you made in WordPress.

In this case, you will no longer encounter the 404 error in WordPress and whenever you try to change the unique link structure in WordPress, this plugin will still be able to identify the content based on their ID and redirect users from the previous unique link. It no longer exists and actually redirects the user to the 404 page to a newer structure of the single link without negatively affecting the ranking and SEO of your site.

Using 301 redirect with htaccess file.

But the second solution to fix the 404 error after changing the WordPress unique link is a bit complicated and I suggest you to use the first method provided by the WordPress SEO plugin as much as possible because almost everyone uses this plugin and if you do not use it, be sure to install and activate it. But if you don’t want to use the plugin for any reason, you can use the htaccess file. Which is located on the host; fix this problem in 5 steps, which I will explain below.

Step 1: Set up unique link structure and site URLs

In the first step, first, go to Settings > Unique Links in the WordPress dashboard and then take a screenshot of the selected structure and settings on this page, because you will need them in the next steps. To learn more about unique links, the training article on working on WordPress settings and refer to the unique links section.

Fix 404 error after changing WordPress unique link

At this stage, if you use the default single link structure of WordPress, i.e. simple single link you do not need to go through the second and fourth steps , because WordPress automatically changes the path on the links in this type of structure, and you only need to follow the third steps. 404 error WordPress after changing the unique link.

In addition, open a notepad file and in a simple editor copy a few links of the contents randomly and put them in it so that after finishing the work you can see whether you followed the steps correctly or not, for this purpose I suggest Put between 5 and finally 10 of the addresses of your posts in this file so that after completing the steps, you can be sure that all the content links will be redirected correctly and in 301 mode to the new structure.

Second step: Creating user redirect codes

For this purpose, you can use the tool provided by the official WordPress SEO plugin website. So go to the address https://yoast.com/research/permalink-helper.php and then enter the form shown on this site similar to the image below based on your site information.

As you can see in the picture, fill in the form information in the following order:

Now click on the orange Create Redirect button to be redirected to the next page and a code similar to the image below will be presented to you.

As you can see, here it is said to change your unique link structure to the name and then the provided code in the htaccess file. put.

Step 3: Change the unique WordPress link

Now, enter the WordPress dashboard and go to Settings > Single Links the type of single link structure of your site on the name and click on the save changes at the bottom of the page.

After changing this step, your unique links will still encounter errors and you have to provide the final step to redirect users.

Step 4: Add the code to the htaccess file. and its implementation

Go to your host and then to edit the htaccess file. Refer to the Host File Manager section. Therefore, after entering the host, click on the File Manager option located in the Files section.

After entering the host file manager, refer to the public_html path and then refer to the path where WordPress is installed and look for the htaccess file. See. If you don’t see this file in the host, click on the Settings that you see on the top right and Show Hidden Files option to display hidden files and finally click on the Save button to save the htaccess file. be displayed to you.

Now on the htaccess file. Right-click and select Edit to go to the editing page of this file. Now put the code that you received in the second step using the tool on the Yoast website right after the END wordpress# and the htaccess file. save the

Exit mobile version