How to edit trailing slashes in WordPress permalinks?

Trailing slash settings might cause SEO issues with duplicate content if they are not properly handled. Unfortunately, the WordPress interface does not make things any simpler.

The forward slash at the end of a URL is known as a trailing slash. Generally, all directory URLs should end with a slash, although single file URLs (e.g. images) should not. However, since the CMS may rewrite URLs on the fly, this rule is no longer as strict.

When it comes to search engine optimization, even a small detail like this may make a big difference. In fact, one of Google's most well-known specialists, John Mueller, emphasized the importance of them on Tweeter some time ago.

Does trailing slash matter for SEO?

Depending on the permalinks settings, trailing slashes may be automatically appended or removed from all URL addresses. In the example below, the trailing slash is highlighted in red to illustrate the difference.

Trailing slash in WordPress URL (example)

At first look, the URLs listed above appear to be the same. The only difference between the two is that the first has a slash at the end, whilst the second does not.

Most of your website's visitors will not notice if you have included a trailing slash or not. Just because something does not make a difference to actual visitors does not mean it will not make a difference to Googlebot. Basically, if the same page can be accessed via two different URLs, it is quite likely that Google will interpret the second URL as a copy of the first.

Regardless of whether you decide to include them in the URL or not, you need ensure that all of the URLs follow your choice and use the same settings. Redirecting non-trailing slash URLs to trailing slash URLs or vice versa is an effective way to ensure this.

The WordPress code, however, does not ensure that visitors and Google will be automatically redirected to a single, chosen version of the URL (with or without the slash). The inconsistent use of trailing slashes in URLs may have a negative SEO impact.

How to use the trailing slash redirect for WordPress permalinks?
Even if you do not know how to code, you can use Permalink Manager to force the preferable trailing-slashes mode with the "trailing slash redirect" function.

Google Analytics reports and trailing slashes inconsistency

What is more, if your website's trailing slashes are inconsistent, you may have seen duplicate URLs in your Google Analytics results. Unfortunately, there is no way to amend the existing statistics data, however you may change how the data is collected in the future.

Google Analytics dashboard

The good news is that this issue can be easily resolved for future data collection. The first option is to apply the URL filters that are included into Google Analytics. There are numerous articles, such as this one, that explain how to use them.

However, forcing one version of the URL via a "301" redirect directly on your server is the most reliable and recommended method. You may accomplish this by using .htaccess code or a third-party plugin like Permalink Manager.

How to control trailing slash settings in WordPress without a plugin?

There is a simple way to keep your trailing slash settings consistent without having to install extra plugins. Most WordPress users and developers are unaware that the trailing slash mode is determined by whether a slash appears at the end of the "Custom Sturcture" field.

You may easily adjust it using the built-in permalink settings. Even users who are unfamiliar with WordPress should find this simple. To do so, go to the "Settings -> Permalinks" section and, depending on your situation, either add or delete the last slash.

"Custom Structure" field affects your trailing slash mode.
The "Custom Structure" field ends with a slash, so all other WordPress URLs will have the trailing slash. Likewise, if it is not present there, the slash will be missing in your website's URLs.

How to add trailing slashes?

Please see the screenshot below to see how to add trailing slashes to WordPress permalinks using only the built-in settings. Because the structure field ends in a slash (see red arrow), WordPress will append the slash to all URLs.

Add trailing slash

How to remove trailing slashes?

Now that we have covered the first option, let us have a look at the second. If you want to remove the trailing slash from WordPress permalinks, you just need to make sure that the "Custom Structure" field does not finish with the slash.

Remove trailing slash from WordPress permalinks

Permalink Manager may be a useful solution to modify trailing slashes settings if you do not have any technical skills or simply do not want to bother with coding. To put it in a nutshell, you may use the plugin to either add or delete the slashes automatically from all WordPress permalinks.

The plugin dynamically filters $wp rewrite->use_trailing_slashes property, therefore all WordPress permalinks (not only the ones filtered with Permalink Manager) will be affected. Of course, this also applies to meta tags (canonical URLs) and sitemaps built by third-party tools like Yoast SEO or RankMath.

You can get back to original mode at any moment! To revert the changes please select "Use default settings" in Permalink Manager settings.

"Trailing slashes" settings in Permalink Manager admin panel.

How to force trailing slash mode with redirect

A canonical redirect is the quickest solution to address duplicate content issues caused by trailing slashes. If you choose to implement the 301 redirect, both users and search engine crawlers will always be sent to to one of two URL versions: with or without slashes.

If you do not know how to code, Permalink Manager may help you in using the redirect. To make it work and force your chosen slashes configuration, enable the "Trailing slashes redirect" option in the plugin settings.

Trailing slash redirect checkbox
To activate the redirect, please turn on "Trailing slashes redirect" option in "Settings -> Redirect settings" panel.

Trailing slashes and cache plugins

Certain caching plugins may cause the Permalink Manager trailing slash redirect to fail. It happens, for example, when you use the WP Rocket plugin. This is because cache plugins will utilize the same cache container for the URL with and without the trailing slash. As a consequence, Permalink Manager will be unable to determine if the URL has a slash or not due to the cache.

To fix this problem, add one of the following snippets to the beginning of the .htaccess file:

# Remove trailing slashes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Force trailing slashes
RewriteEngine on
RewriteCond %{REQUEST_URI} !(/$|.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]

How to add/remove slashes conditionally?

As indicated before, the user-selected mode will be forced all WordPress permalinks. Nevertheless, you may adjust this programmatically and remove/add the slashes for certain post types or taxonomies.

Below you can find an example how to remove the trailing slashes from all permalinks with the exception of chosen taxonomies and post types. The following code snippet should be added to your (child) theme’s functions.php file.

Add trailing slash to URL WordPress (custom taxonomy) permalinks:

function pm_term_permalinks_trailing_slashes($permalink, $term) {
if(!empty($term->taxonomy) && (in_array($term->taxonomy, array('category', 'product_cat')))) {
$permalink = trailingslashit($permalink);
return $permalink;
add_filter('permalink_manager_filter_final_term_permalink', 'pm_term_permalinks_trailing_slashes', 999, 2);

Remove trailing slash from URL WordPress (post & product) permalinks:

function pm_post_permalinks_trailing_slashes($permalink, $post) {
if(!empty($post->post_type) && (in_array($post->post_type, array('post', 'product')))) {
$permalink = untrailingslashit($permalink);
return $permalink;
add_filter('permalink_manager_filter_final_post_permalink', 'pm_post_permalinks_trailing_slashes', 999, 2);

Prevent redirect loop (trailing slash redirect)

Finally, if you activated the "Trailing slash redirect" option and used one of the above snippets, you will require another one. The redirect function will normally force or remove the slash from all WordPress permalinks. To avoid the redirect loop, deactivate programatically the redirect for permalinks where slashes should be used conditionally.

function pm_stop_trailing_slash_redirect($correct_permalink, $redirect_type, $queried_object) {
if(!empty($queried_object->post_type) && (in_array($queried_object->post_type, array('post', 'product'))) && $redirect_type == 'slash_redirect') {
return false;
return $correct_permalink;
add_filter('permalink_manager_filter_redirect', 'pm_stop_trailing_slash_redirect', 9, 3);
Go up