I need to redirect all my WordPress posts under the sub-directory /plays/
to the home directory (/
) except for the landing page.
example.com/plays/hello
you will be redirected to example.com/hello
example.com/plays
or example.com/plays/
you will stay on that page. How can I do this? I'm assuming it has to be done through a redirect via .htaccess
but I don't know how.
The following rule should work :
RewriteEngine on
#if the request is for "/plays" or "/plays/", skip the rule#
RewriteCond %{REQUEST_URI} !^/plays/?$
#otherwise redirect to homepage#
RewriteRule ^plays/(.+)$ http://domain.com/$1 [R,L]