I’ve seen several answers to this, but none of them seem to work on subdirectories or nested URLs.
Basically, I want to redirect everything on a domain, no matter whether specified with a direct URL or a directory, no matter how deeply nested, to a “site closed” or “maintenance” page, on the same domain.
For example, all of these:
example.com
example.com/page.html
example.com/sub
example.com/sub/page.html
example.com/sub/sub2
example.com/sub/sub2/page.html
…should redirect to https://example.com/index_closed.html
I can get it to work on example.com, but not nested directories.
Also, it should NOT redirect .css files, if possible. Thanks!
2
Answers
I found that the following works:
RewriteBase /
RewriteRule ^$ https://example.com/index_closed.html [R=301,L]