Articles on: FAQs

How to force trailing slash in URLs

Force trailing slash in URLs

Apache:

Make sure to add this code above FlyingPress rules in htaccess.

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} /+[^\.]+$ 
    RewriteCond %{REQUEST_URI} !^/wp-json
    RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
</IfModule>


Nginx:

if ($request_uri !~ "^/wp-json") {
    rewrite ^([^.]*[^/])$ $1/ permanent;
}

Updated on: 29/05/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!