How to redirect everything to a new domain except root page and WP directories for WordPress sites

If you ever run a WordPress site that was going to be decomissioned, and you needed to redirect everything to the new domain running a non-WordPress site to the new domain’s root page, but you do not want to redirect the root page of your old domain and any WordPress directories, spare 2 hours of your life and 10 varieties of cuss words. Here’s your answer.

Remove the following code in your .htaccess file:

RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

And replace it with this gist.

You’re welcome.

©2019 Hazrul Azhar - Split Template by One Page Love