Categories
Energy

WordPress: Redirect All Traffic Except Admin Page

As much as it breaks my heart, it is time to fully migrate everything from mistypedURL.com over to Castello.me. Pointing all the old links from Google searches to their new location can be accomplished with some changes to the .htaccess file. Found via Stack Overflow, an extra line can exempt the WordPress admin panel from redirection in the event something else needs to be recovered.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/wp-admin.*
RewriteRule ^(.*)$ https://example.com$1 [R=301, L]
</IfModule>

If one is not comfortable editing the .htaccess file, this can also be accomplished via PHP or a WordPress plugin.