Question

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.

Was it helpful?

Solution

Change your RewriteRule to

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

OTHER TIPS

These rules should go before your WordPress rules, make sure that rewriting is on, and set a rewrite base of / -

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} mydomain.com [NC]
RewriteRule ^about-my-site/? about [R=301,NC,L]
</IfModule>

Test here: http://htaccess.madewithlove.be/

input url
http://mydomain.com/about-my-site/

output url
http://mydomain.com/about

debugging info
1 RewriteEngine On  
2 RewriteBase / 
3 RewriteCond %{HTTP_HOST} mydomain.com [NC]        This condition was met
4 RewriteRule ^about-my-site/? about [R=301,NC,L]   This rule was met, the new url is http://mydomain.com/about
Test are stopped, because of the R in your RewriteRule options. A redirect will be made with status code 301
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top