{"id":167936,"date":"2017-09-24T13:00:49","date_gmt":"2017-09-24T13:00:49","guid":{"rendered":"https:\/\/premium.wpmudev.org\/blog\/?p=167936"},"modified":"2019-09-19T16:12:03","modified_gmt":"2019-09-19T16:12:03","slug":"domain-mapping-without-multisite","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/domain-mapping-without-multisite\/","title":{"rendered":"How to Use Domain Mapping When You\u2019re Not Running Multisite"},"content":{"rendered":"<p>Mapping domains is super easy in Multisite. It lets you create as many sites as you want in one WordPress installation and then makes them all behave as if they&#8217;re separate sites on their own domain.<\/p>\n<p>But sometimes you want to map a domain when you&#8217;re not running Multisite. Say you&#8217;ve created a site in its own WordPress installation somewhere on your server, maybe in a subdirectory, but you want to direct it to an external domain name. You want the custom domain name to show up in the browser, instead of the primary domain with the subdirectory or subdomain showing up.<\/p>\n<p>By default, WordPress domain mapping functionality only works with Multisite setups, so you can&#8217;t use that to map domains within a single WordPress installation. And if you&#8217;re on hosting accounts that allow only one domain, you can still bypass that restriction with this method.<\/p>\n<p>The good news is that you can map a domain to a subdirectory on another domain, so it works in just the same way. We&#8217;ll be doing this by using cPanel and changing some WordPress settings.<\/p>\n<p>How to map domains in\u00a0four steps:<\/p>\n<ol>\n<li>Register the domain and configure it to point to your server if it isn&#8217;t already.<\/li>\n<li>Add the domain to your hosting account, using cPanel.<\/li>\n<li>Wait for your DNS changes to take effect.<\/li>\n<li>Update the Subsite addresses (URLs).<\/li>\n<\/ol>\n<p>So let&#8217;s go through the process step-by-step.<\/p>\n<h3>1. Register The Domain And Point It To Your Server<\/h3>\n<p>You can&#8217;t do any of this without a domain registered. So begin by registering a domain with the registrar of your choice.<\/p>\n<p>If you register your domain with your hosting provider, it will automatically direct to their nameservers, so you won&#8217;t then have to configure it to point to your server. You can go straight to Step 2.<\/p>\n<p>But if you use different providers for hosting and domains (<a href=\"https:\/\/wpmudev.com\/blog\/keep-domains-wordpress-separate\/\" target=\"_blank\" rel=\"noopener\">which is highly recommended<\/a>), or if your client has registered the domain and you&#8217;ve created a site for them,\u00a0you must\u00a0<a href=\"https:\/\/wpmudev.com\/blog\/the-ultimate-guide-to-dns-for-wordpress\/\" target=\"_blank\" rel=\"noopener\">configure the DNS settings for the domain<\/a>.<\/p>\n<p>Go to your domain registrar&#8217;s admin screen and edit one of the following options:<\/p>\n<h4>Nameservers<\/h4>\n<p>If you want all the DNS records of the domain to point to your hosting server (which for most of us means the domain itself and any email addresses associated with it), then change its nameservers (NS records).<\/p>\n<p>I use Big Wet Fish for my domains. Here&#8217;s their admin screen for changing nameservers:<\/p>\n<figure class=\"wp-caption alignnone\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1050x1050 size-1050x1050\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/editing-nameservers.png\" alt=\"Big Wet Fish nameserver editing\" width=\"1050\" height=\"691\" \/><figcaption class=\"wp-caption-text\">The admin screen for changing nameservers on my domain.<\/figcaption><\/figure>\n<p>The screen for your domain registrar will look different but will be essentially similar. You get the nameservers from your hosting provider &#8211; they&#8217;ll send these when you sign up and you can find them in their admin screens or on cPanel. I use SiteGround for my hosting, and they display their nameservers in cPanel:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-600x600 size-600x600\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/siteground-cpanel-nameservers-e1505483671830.png\" alt=\"nameservers displayed in cPanel\" width=\"600\" height=\"384\" \/><\/p>\n<p>That gives me the values I need to add to my registrar&#8217;s nameservers admin screen.<\/p>\n<p><em>Note: If you want to direct a domain to your nameservers but have your email hosted elsewhere, and you&#8217;ve directed the domain to your hosting provider&#8217;s nameservers, then you need to edit the DNS for email (or the MX records) in your hosting provider&#8217;s admin screens.<\/em><\/p>\n<h4>CNAME<\/h4>\n<p>I&#8217;ve mentioned above that if you don&#8217;t want your domain&#8217;s email address hosted with your hosting provider, you can edit this on your hosting account. This means that your DNS for email will redirect twice. If you want to avoid this and either keep email with the domain registrar or direct it somewhere else (such as Gmail) from your registrar&#8217;s admin screens, you can do this by editing the CNAME value for your domain instead.<\/p>\n<p>The CNAME points to the domain you want the original domain to redirect to. So if you want <em>mydomain.com<\/em> to point to <em>myhosting.com\/mydomain<\/em>, you&#8217;d add <em>myhosting.com\/mydomain<\/em>\u00a0in your domain registrar&#8217;s admin screens.<\/p>\n<p>Here&#8217;s my registrar&#8217;s DNS admin screen, showing the options you have:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-600x600 size-600x600\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/DNS-editing.png\" alt=\"DNS editing showing options for DNS management\" width=\"600\" height=\"393\" \/><\/p>\n<p>If you use the CNAME, select <strong>CNAME (Alias)<\/strong> and type the address for the new site on your hosting (i.e.\u00a0<em>myhosting.com\/mydomain<\/em>) in the <strong>Address<\/strong> field. The domain will automatically point to the right place and you can skip the next step which is creating the add-on domain.<\/p>\n<h4>A Record<\/h4>\n<p>Another option is to configure the A record for your domain to point to the IP address where your hosting is.<\/p>\n<p>Like the CNAME record, this only affects the website, not email. Use the same DNS screen as you would for the CNAME, select <strong>A<\/strong> and type in the IP address. Your hosting provider will give you this or you&#8217;ll be able to find it in cPanel or your hosting admin screens.<\/p>\n<p><em>Note: If you do this, you must still set up the add-on domain.<\/em><\/p>\n<h3>2. Create An Add-On Domain<\/h3>\n<p>You can skip this step if you used the CNAME option above.<\/p>\n<p>In cPanel, which your hosting provider will give you access to, go to the <strong>Domains<\/strong> section:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-600x600 size-600x600\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/cpanel-domains.png\" alt=\"domains section of cPanel\" width=\"600\" height=\"184\" \/><\/p>\n<p>Select <strong>Add-on Domains<\/strong>. This will take you to a screen where you need to enter the domain name that you&#8217;ve directed to your server:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-600x600 size-600x600\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/addon-domains.png\" alt=\"configuring an addon domain\" width=\"600\" height=\"332\" \/><\/p>\n<p>Type the URL of the domain (without <em>http<\/em> or <em>www<\/em>) in the <strong>New Domain Name<\/strong> field, and enter the subdirectory which stores your site in the <strong>Document Root<\/strong> field. Using the example above, I&#8217;d type <em><strong>mydomain.com<\/strong><\/em> and <em><strong>mydomain<\/strong><\/em>, respectively.<\/p>\n<p>If you want to create a FTP account for this site, then add the details in the <strong>FTP Username<\/strong> field. Create a password for your new domain and click on <strong>Add Domain<\/strong>.<\/p>\n<h3>3. Wait For DNS To Take Effect<\/h3>\n<p>This can take anything from a few minutes to even 48 hours. And you have no control over it. You simply have to wait, as it takes some time for your domain&#8217;s updated DNS records to propagate.<\/p>\n<p>If you want to monitor its progress, check out the <a href=\"https:\/\/www.whatsmydns.net\/\" target=\"_blank\">whatsmydns<\/a> site to see where in the world your DNS is resolving correctly. Here&#8217;s my site&#8217;s DNS:<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"wp-caption alignnone\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1050x1050 size-1050x1050\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/whatsmydns.png\" alt=\"Whatsmydns.net shows my site's name servers\" width=\"1050\" height=\"569\" \/><figcaption class=\"wp-caption-text\">My site&#8217;s DNS.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p><em>Note: My DNS points to CloudFlare because I&#8217;m <a href=\"https:\/\/wpmudev.com\/blog\/multisite-hummingbird-cloudflare-speed\/\" target=\"_blank\">using that with our Hummingbird plugin for performance<\/a>.<\/em><\/p>\n<p>If there are any problems, this is a useful tool to track them.<\/p>\n<h3>4. Update the Site Addresses (URLs)<\/h3>\n<p>Once you&#8217;ve redirected your domain, created an add-on domain and the DNS changes have taken effect, the redirect will work. When you type <em>mydomain.com<\/em> into a browser, it&#8217;ll direct you to\u00a0<em>myhosting.com\/mydomain<\/em>.<\/p>\n<p>But the URL in the browser will still show up as\u00a0<em>myhosting.com\/mydomain<\/em>. You want it to show up as <em>mydomain.com<\/em>.<\/p>\n<p>To change this go to <em><strong>Settings &gt; General<\/strong><\/em> in your WordPress admin screens. The two fields you need to edit are <em><strong>WordPress Address (URL)<\/strong><\/em> and <em><strong>Site Address(URL)<\/strong><\/em>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-600x600 size-600x600\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/09\/general-settings-before.png\" alt=\"editing site url and WordPress url in settings\" width=\"600\" height=\"307\" \/><\/p>\n<p>Both these read\u00a0<em><strong>myhosting.com\/mydomain\u00a0<\/strong><\/em>now. Edit them, so they read <em><strong>mydomain.com.<\/strong><\/em>\u00a0And then click <em><strong>Save Changes<\/strong><\/em>.<\/p>\n<p>Because you&#8217;ve changed your site&#8217;s domain, you need to log in again. If you find your site doesn&#8217;t work properly, then <a href=\"https:\/\/kb.iu.edu\/d\/ahic\" rel=\"noopener\" target=\"_blank\">clear your browser cache<\/a> and <a href=\"https:\/\/phoenixnap.com\/kb\/how-to-flush-dns-cache\" rel=\"noopener\" target=\"_blank\">flush your DNS cache<\/a>. Once you&#8217;ve done that, you&#8217;ll find that your site&#8217;s domain mapping is the same as it is with WordPress Multisite domain mapping.<\/p>\n<h3>Mapping Domains Is Easier Than You Think<\/h3>\n<p>By following these four steps, you can map a domain you&#8217;ve registered to a subdirectory of your hosting account. It&#8217;ll behave as if it&#8217;s hosted along with the domain. This can be useful if you need to direct a second or alternative domain to your site. You can safely create multiple instances of WordPress on your hosting account without having to set up multiple hosting accounts, each with their own domain. This will save you money while getting the same results.<\/p>\n<p>Get mapping!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mapping domains is super easy in Multisite. It lets you create as many sites as you want in one WordPress installation and then makes them all behave as if they&#8217;re separate sites on their own domain. But sometimes you want to map a domain when you&#8217;re not running Multisite. Say you&#8217;ve created a site in [&hellip;]<\/p>\n","protected":false},"author":761786,"featured_media":168002,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[11138,9778],"tutorials_categories":[],"class_list":["post-167936","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-domain-mapping","tag-domains"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/167936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/761786"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=167936"}],"version-history":[{"count":15,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/167936\/revisions"}],"predecessor-version":[{"id":178905,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/167936\/revisions\/178905"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/168002"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=167936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=167936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=167936"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=167936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}