If you want to redirect everything from root, excluding the /2018/asdfa
directory (that contains WordPress), into a new subdirectory then you can do something like the following at the top of your .htaccess
file:
RewriteEngine On
RewriteRule !^2018/asdfa /newdirectory%{REQUEST_URI} [R=302,L]
UPDATE: What if I have more than one directory to excluding? like: 2018, 2019, 2020
If it's just directories like you mention, then it would be easiest to just use alternation in the regex. For example:
RewriteRule !^20(18|19|20)/asdfa /newdirectory%{REQUEST_URI} [R=302,L]
The (18|19|20)
subpattern matches either 18
, 19
or 20
.
If you wanted to match anything that looks-like a "recent" year then you can use a more generalized pattern. For example:
RewriteRule !^20[12]\d/asdfa /newdirectory%{REQUEST_URI} [R=302,L]
20[12]\d
matches the strings (ie. directories) 2010
to 2029
(inclusive). [12]
is a character class that matches either 1
or 2
. And \d
is a shorthand character class that matches any digit 0-9 (the same as [0-9]
).