Remove the Date from WordPress URLs
WordPress has an SEO friendly URL structure, where numerous link formats can enable the exclusive WordPress customization options. It includes the ones that add dates to the WordPress postURLSs. Non-readable link structure for page and post URLs are used by default, where post ID is added in the URL.
This structure neither looks good nor holds any meaning. Luckily, WordPress offers you the option of changing it to more substantial and SEO friendly URLs. This implies that you can also alter or remove the date from your WordPress URLs.
Why do you need to remove the Date?
When you choose the “day and name” and “month and name” options, the date parameters would be added to the WordPress URLs. They are usually better than the default ones and are also SEO friendly. Their appearance would be along the lines of:
- Month and name: http://reference.com/2020/09/sample-post/
- Day and name: http://reference.com/2020/09/21/sample-post/
The presence of dates in the URLs has become a trend of the past. Many posts in your site would require one or the other updated WordPress customizations, including changing its content. Once the alteration is done, the URL’s unchanged date would still show it to be old.
Steps to Remove the Date from the URL
Before taking any measures, having a complete WordPress backup of your site is crucial, so that you can restore it with ease if this process does not have good results. There are two ways of doing so, but the first step of changing the settings to remove the date remains the same. The steps are:
Changing Settings to Remove the Date
- Permalinks settings need to be changed. For this, you need to navigate to ‘Settings> Permalinks’ on the left side of the bar of the WordPress admin area.
- Choose ‘Name’ as the option and click on the ‘Save Changes’ button to confirm and store the changes.
How to Preserve SEO Rankings
1. Plugin Option
This is the first option, where a plugin is used to carry on the process of redirecting users to the new links. Proper redirects need to be set up once you have removed the dates.
It removes the risk of users being shown a 404 error while being transferred to the updated URLs. In this way, search engines would also be updated about the old URLs being moved to the new ones.
The steps are:
- Install and activate a redirection plugin.
- When it activates, search for the ‘Tools> Redirection” page and then select the ‘Start Setup’ option.
- Two options would be displayed. You could choose to let the plugin detect and alert you in case the posts URL is changed so that a log of redirects can be kept, or you could click on the ‘Continue Setup’ button.
- Some tests would be run by the plugin to check if everything works well, after which you can select the ‘finish setup’ option at the top or scroll down to the section that reads ‘Add new Redirection’.
- A form of ‘Source and Target fields’ would be displayed. ‘Source’ is the section in which you will need to type down the old URL structure while ‘Target’ would be the new URL location.
- If you used the ‘Day and name’ URLs, you need to enter some values in the source and target fields. It would look like:
- In case the ‘Month and name’ URLs were being used:
- Select ‘Regex’ and click on the ’Add Redirect’ option to save these changes.
- The users will now be redirected to the new name-based URLs.
Rewrite the htaccess
This method can be used only when your WordPress server is running ‘Apache’ and not ‘Nginx’, and that your Apache configuration support ‘.htaccess’ files for URL rewrites.
After changing the settings in the permalinks section, go through the following steps:
- To Supper WordPress, a URL rewrite with the htaccess needs to be done. To change the permalink structure for WordPress posts, find the .htaccess file. Connect to your web host via SFTP to carry this out quickly.
- Once you are connected, search for the .htaccess file at the WordPress installation root, where you will put the code.
- Paste the following lines:
Must Read: Other blogging tips
## To change example.com/2020/01/01/post- slug to example.com/post- slug
<IfModule mod_rewrite.c> RewriteRule ^([0-9]+)/ ([0-9]+)/ ([0-9]+)/(.*)$ /$4 [R-301,NC,L] </IfModule>
- Save and upload the file back to the server. The data from the WordPress post URLs have been removed without triggering the 404 errors.
Without the need of a WordPress expert, you can follow this guide with ease to do away with redundant posts with dates. Changing permalinks seem challenging, so all precautions should be taken before going ahead with the procedures.