Search code examples
.htaccesshttp-redirectwordpresstrailing-slash

Remove trailing slash in WP multisite .htaccess file


I've created an .htaccess file that contains redirects for one site that is part of a larger WordPress Multisite install.

The .htaccess content starts with this (necessary because the same .httacess file must be used for multiple sites:

RewriteCond %{HTTP_HOST} ^mydomain.com [nc]

And then contains a series of rewrites, like so:

RewriteRule ^about-my-site$ about [R=301,NC,L]

If I visit mydomain.com/about-my-site, I am correctly redirected to mydomain.com/about However, if I visit mydomain.com/about-my-site/ (please note trailing slash), I get a "Page not found" error.


Solution

  • Change your RewriteRule to

    RewriteRule ^about-my-site/?$ about [R=301,NC,L]