To solve this problem, you must go to the .htaccess file after creating the new redirect. From there, you will have to make a modification that you will see in detail later. Save the changes and test the redirect.
Next, you will see in detail how to solve the described problem.
Explanatory Example
Let's say you just created a new website for yourself or a client, and the new website is hosted on a server that uses the cPanel control panel.
If your old website was created in HTML, PHP, or a different language than your new WordPress site, your new "About Us" page might look like this:
Old website: http://mysiteweb.com/about-us.html
New website: http://mysiteweb.com/about-us/
It is very likely that some users who visited your old website in the past bookmarked the old email address. Also, in search engines, your old "About Us" page is already listed under this old URL. However, if a user who never visited your old website:
http://mysiteweb.com/about-us.html, goes to the new http://mysiteweb.com/about-us/, they will receive an error message because the website does not exist.
At this point, you would need to create a redirect.
The redirect allows anyone who goes to http://mysiteweb.com/about-us.html to be automatically redirected to a new website: http://mysiteweb.com/about-us/. This will solve the error. Additionally, a permanent redirect (301) will notify Google that this is the new location of your old website address.
So far, so good!
So, you need to go to the cPanel control panel and create a redirect. If you want to learn more about how to set up a redirect using cPanel, we suggest you visit the tutorial on How to configure domain redirection.
To test it, below we show you the steps to follow to create a redirect from cPanel.
How to create a redirect from cPanel?
In cPanel, click on the Domains section -> Redirects, located at the top of the screen.
Select the redirect category, Permanent or Temporary.
Choose whether you want to use a redirect https?://(www.)? to all public web domains or to only one.
On the next line after the forward slash (/), write the suffix of the URL you want to redirect from. (In our example, we are redirecting from http://mysiteweb.com/about-us.html, we write: about-us.html.
Then, write the complete URL you want to redirect to. (In our example, we write: http://mysiteweb.com/about-us/).
Choose whether you want to redirect, With www, Without www, or Both. If you are not sure, leave it with the default value of Both.
Select the Wildcard Redirect box and click the "Add" button.
Finally, check the redirect made to the original URL in your browser.
With this, you create a redirect to your "About Us" page.
But if you try to access your new website and realize that ... IT DOESN'T WORK.
Tip. To avoid doubts, you need to make sure you have accessed the correct URL. (In our example, http://mysiteweb/about-us/ (step number 5).
The most effective solution to this problem
As we mentioned at the beginning, the solution is to edit the .htaccess file. This is a very simple action and you can do it without any problem. If you want to learn how to safely edit .htaccess files with a WordPress plugin, we suggest you visit this guide on "How to modify the .htaccess file".
Here is the code for the .htaccess file that is the same as your WordPress installation:
RewriteOptions inherit # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress RewriteCond %{HTTP_HOST} ^mysiteweb.com$ [OR] RewriteCond %{HTTP_HOST} ^www.mysiteweb.com$ RewriteRule ^main.htm$ "http://mysiteweb.com/" [R=301,L]
Afterwards, take the # END WordPress lines and move them above the # BEGIN WordPress line and at the bottom of the RewriteOptions inherit rewrite rules.
The result will look like this:
RewriteOptions inherit RewriteCond %{HTTP_HOST} ^mysiteweb.com$ [OR] RewriteCond %{HTTP_HOST} ^www.mysiteweb.com$ RewriteRule ^main.htm$ "http://mysiteweb.com/" [R=301,L] # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress
This is to edit the .htaccess file.
Finally, go to your website: http://mysiteweb.com/about-us/ and make sure it opens without any errors.