When you begin writing your posts, you might not be familiar with the permalink structure. But to make your permalink structure look clean, you must remove unnecessary words from your URLs.
If you’ve removed the base from your permalink structure, you must consider redirecting your old URLs to the new URLs to ensure you don’t lose any search engine traffic due to these broken links.
In this knowledgebase article, we’ll walk you through how you can remove a particular word from all your URLs. This can be handled easily in Rank Math by setting up redirections in the Redirection Manager.
Removing a Particular Word from the URL
1 Navigate to Redirections
At first, head over to WordPress Dashboard > Rank Math > Redirections, as shown in the image below. If the Redirections Manager is unavailable in your Rank Math menu, ensure that you’ve enabled the Redirections module from Rank Math > Dashboard > Modules inside your WordPress admin area.
2 Add a New Redirection
In the Redirections Manager, click the Add New button as shown below.
3 Create a Regex Redirection
To remove a particular word from all your URLs, you need to create a redirection with the regex (regular expression) matching type.
You need to instruct Rank Math to look for a specific word in the URL with a regex. And when the URL with a specific word matches your regex, Rank Math would remove the word from the URL and return the URL’s remaining part. The resulting URL would be the destination URL or the URL where your visitor would be redirected to when they land on your old links.
The regex for removing a word would be:
Regex Source URL: ^wordtoreplace/(.*) Destination URL: /$1
In the Regex Source URL, you’ll need to replace
wordtoreplace with the word you wanted to remove from the URL.
Now in the Add Redirections dialog box, add your source and destination URLs and select the matching type as Regex from the drop-down list. This is how the redirect will look inside the dialog box.
Once you’ve added the Source URL, Regex matching type, and Destination URL, set the status to Activate and click the Add Redirection button.
Now that the redirection is activated, for instance, a visitor landing on your website’s page
https://www.example.com/wordtoreplace/post-url/ would be redirected to
https://www.example.com/post-url/ with a 301 redirection.
And that’s it! We hope you were able to remove a particular word from the URL with this tutorial. If you still have questions about using our Redirection feature, feel free to contact our support team — as we’re always here to help.