How to add or remove trailing slashes in WordPress URLs
WordPress decides the trailing slash from one place: the end of the permalink structure under Settings → Permalinks. A structure ending in /, such as /%postname%/, gives every URL a trailing slash. One without, /%postname%, removes it everywhere. Core then 301-redirects the other form to the one you chose.
Search engines treat /pricing and /pricing/ as two addresses. Either convention works as long as one is the real URL and the other redirects to it, which WordPress handles for its own pages once the setting is right.
Step by step
1. See what your site does now
Open Settings → Permalinks and read the selected structure. The built-in options Day and name, Month and name and Post name all end in a slash. Numeric (/archives/%post_id%) does not, and a Custom Structure ends however you type it. Then test both forms of a real post:
curl -sI https://example.com/a-post | grep -iE "^HTTP|^location"
curl -sI https://example.com/a-post/ | grep -iE "^HTTP|^location"
One should return 200 and the other a 301 pointing at it. That is a healthy setup, and if you see it you may have nothing to change.
2. Choose a convention and keep it
On an existing site, keep whatever is live unless it is inconsistent. Switching conventions changes every URL on the site and makes every existing link and listing pass through a redirect. On a new site, the default with a trailing slash is the path of least resistance, since it is what themes, plugins and most documentation assume.
3. Set the permalink structure
- Go to Settings → Permalinks.
- For a trailing slash, pick Post name or end your custom structure with
/. - For no trailing slash, choose Custom Structure and enter the structure without the final slash, for example
/%postname%. - Click Save Changes.
The setting applies to posts, pages, categories, tags, author and date archives and paged URLs, because WordPress runs every generated link through the same function.
4. Check the links WordPress prints
Reload a post and inspect the links in the menu, the canonical tag and the XML sitemap. They should all use your chosen form. If the canonical tag and the address bar disagree, something outside WordPress is rewriting the URL, usually a server rule from step 5.
5. Remove conflicting server rules
A site that was moved or tuned by hand often carries its own slash rule in .htaccess or the nginx config. When that rule adds a slash and WordPress removes it, or the reverse, the browser reports too many redirects. Search .htaccess for a RewriteRule that ends in /$1/ or strips /$, and remove it. WordPress's canonical redirect is enough. The one case for a server rule is performance on a very busy site, and then it must match the WordPress setting exactly.
6. Leave files and the homepage alone
Two things never follow the setting. Real files such as /robots.txt, /sitemap.xml and anything under /wp-content/uploads/ have no trailing slash. The homepage is always the bare domain, and https://example.com and https://example.com/ are the same request, so there is nothing to redirect.
7. Retest and update hard-coded links
Repeat the two curl commands. Then fix links you typed by hand in menus, widgets and content that use the non-canonical form. Each one works, but it costs visitors and crawlers a redirect. Custom menu links are the usual offenders, because WordPress stores them exactly as typed.
Does the trailing slash matter for SEO
Not as a ranking factor. What matters is consistency: one form returns 200, the other redirects, and canonical tags, internal links and the sitemap all agree. Problems come from mixtures, such as a sitemap listing slashed URLs while internal links use unslashed ones, which sends every internal click through a redirect and shows up in Search Console as Page with redirect for half your links.
With Hydrogen SEO
The plugin builds canonical URLs and sitemap entries from WordPress's own permalinks, so both follow the permalink structure automatically. After changing the structure, open your sitemap from Hydrogen SEO → Sitemap: changing the permalink structure clears the sitemap cache, so the new form appears on the next request. For redirects you create by hand in Hydrogen SEO → Redirections, type the To URL in the form your site uses so the rule does not hand off to a second redirect.
Common questions
How do I remove the trailing slash from WordPress URLs?
Go to Settings → Permalinks, choose Custom Structure, enter your structure without the final slash, such as /%postname%, and save. WordPress then redirects slashed URLs to the unslashed form.
Is a trailing slash better for SEO?
Neither form ranks better. Pick one, make sure the other redirects to it, and use the same form in canonicals, links and the sitemap.
Why do I get a redirect loop after changing it?
A server rule is forcing the opposite of the WordPress setting. Remove the rule from .htaccess or the nginx config, or change it to match.