KDK Domain URL Normalizer (by Kodeka)
A simple plugin to rewrite multiple domains or subdomains to a single domain in the site's HTML output.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/fevangelou/kdk_domain_url_normalizer/archive/refs/heads/master.zipKDK Domain URL Normalizer (v1.1.0 / Jan 2020)
A simple plugin to rewrite multiple domains or subdomains to a single domain in the site's HTML output.
The plugin can also normalize the domain protocol (http:// to https:// and vice versa) as well as additional ports (e.g. example.com:8080 to www.example.com and vice versa).
Some practical uses:
- Normalize the domain after migrating WordPress from a test domain to the production one.
- Allow the WordPress admin to be served from a different subdomain (e.g. when WordPress is served over a CDN and you want to avoid any caching of static data etc.). This would require passing on multiple domains/subdomains in your wp-config.php file like so:
// Map multiple domains in WordPress define('KDK_WP_PRIMARY_DOMAIN', 'www.domain.tld'); define('KDK_WP_SECONDARY_DOMAINS', serialize(array( 'www2.domain.tld', 'admin.domain.tld', 'whatever.domain.tld' ))); define('KDK_WP_DOMAIN_PROTOCOL', 'https');
if (in_array($_SERVER['HTTP_HOST'], unserialize(KDK_WP_SECONDARY_DOMAINS))) { define('WP_HOME', KDK_WP_DOMAIN_PROTOCOL.'://'.$_SERVER['HTTP_HOST']); define('WP_SITEURL', KDK_WP_DOMAIN_PROTOCOL.'://'.$_SERVER['HTTP_HOST']); } else { define('WP_HOME', KDK_WP_DOMAIN_PROTOCOL.'://'.KDK_WP_PRIMARY_DOMAIN); define('WP_SITEURL', KDK_WP_DOMAIN_PROTOCOL.'://'.KDK_WP_PRIMARY_DOMAIN); }
// Share cookies across subdomains define('COOKIE_DOMAIN', '.domain.tld');
- When you want to switch your site from HTTP to HTTPS and you want all internal resources to be properly linked through HTTPS as well.
## To Do
- Add option to control caching (home/inner pages)
- Add option for executing in the backend
- Add new *.ini based language file
## Installation
Download the repo from https://github.com/kodeka/kdk_domain_url_normalizer/archive/master.zip and extract the zip file. Rename the created folder to "kdk_domain_url_normalizer". Zip that folder. Install the newly created zip file like any other WordPress plugin through the plugin manager.
## License & Credits
Licensed under the GNU/GPL license (https://www.gnu.org/copyleft/gpl.html).
Copyright (c) 2018 - 2020 Kodeka OÜ. All rights reserved.