{"id":875,"date":"2024-05-07T11:44:52","date_gmt":"2024-05-07T11:44:52","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/how-to-serve-the-images-from-a-custom-domain\/"},"modified":"2025-09-15T06:53:10","modified_gmt":"2025-09-15T06:53:10","password":"","slug":"how-to-serve-the-images-from-a-custom-domain","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/how-to-serve-the-images-from-a-custom-domain\/","title":{"rendered":"How can I set up the plugin to serve images from a custom subdomain?"},"content":{"rendered":"\n<div class=\"callout-red\">\n<strong>Important:<\/strong> If you are on a free plan or have purchased one-time credit packages, you will <strong>not<\/strong> be able to add a custom subdomain unless you use your own CDN to deliver the images instead of ShortPixel&#8217;s. Custom subdomains with ShortPixel&#8217;s CDN are exclusively available to users who have subscribed to an unlimited or monthly\/yearly plan.\n<\/div>\n\n\n\n<div class=\"callout-blue\">\nIf all you want to do is use <strong>your own<\/strong> CDN to deliver the images, and you don&#8217;t care about the &#8220;Accept requests only from specific domains&#8221; feature, you can just follow <a href=\"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/can-i-use-a-different-cdn-with-shortpixel-adaptive-images\/\">this simpler tutorial<\/a>.\n<\/div>\n\n\n\n<p>By default:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ShortPixel Image Optimizer (SPIO)<\/strong> serves images from <code>spcdn.shortpixel.ai<\/code><\/li>\n\n\n\n<li><strong>ShortPixel Adaptive Images (SPAI)<\/strong> serves images from <code>cdn.shortpixel.ai<\/code><\/li>\n<\/ul>\n\n\n\n<p>If you\u2019d prefer to serve images from your own subdomain (like <code>img.example.com<\/code>), here\u2019s how to set it up:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/shortpixel.com\/login\" target=\"_blank\" rel=\"noopener\">Log in<\/a> to your ShortPixel account and from the dashboard, click <a href=\"https:\/\/shortpixel.com\/associated-domains\" target=\"_blank\" rel=\"noopener\">Associate Domains<\/a>.<\/li>\n\n\n\n<li>Add your domain if it wasn&#8217;t there yet: <a href=\"https:\/\/shortpixel.com\/knowledge-base\/article\/how-to-associate-a-domain-to-my-account\/\" rel=\"noopener\">How can I associate a domain to my account?<\/a><\/li>\n\n\n\n<li>Click the <strong>gear icon<\/strong> next to your domain to open its settings<br><img decoding=\"async\" width=\"600\" height=\"235\" class=\"wp-image-1670\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101346.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101346.jpg 1119w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101346-300x118.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101346-1024x402.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101346-768x301.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101346-360x141.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n\n\n\n<li>Click on the <strong>Custom CDN Domain<\/strong> button.<br><img decoding=\"async\" width=\"600\" height=\"261\" class=\"wp-image-1671\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101509.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101509.jpg 1125w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101509-300x130.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101509-1024x445.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101509-768x334.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_101509-360x156.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n\n\n\n<li>Think of a suitable subdomain name for the delivery of your images, such as <code class=\"inline-code\">cdn<\/code>, <code class=\"inline-code\">img<\/code>, <code class=\"inline-code\">images<\/code>, <code class=\"inline-code\">media<\/code>, and so on. For example, if your website is <code class=\"inline-code\">example.com<\/code> and you choose <code class=\"inline-code\">img<\/code> subdomain, your images will be served from <code class=\"inline-code\">img.example.com<\/code>.<\/li>\n\n\n\n<li>Enter your preferred subdomain name in the &#8220;<strong>Enter your subdomain<\/strong>&#8221; text box.<\/li>\n\n\n\n<li>If you want to use your own CDN and do not want to use ShortPixel&#8217;s CDN, check the box &#8220;I use my own CDN&#8221;.<\/li>\n\n\n\n<li>Click on the red <strong>Setup Custom Domain<\/strong> button.<br><img decoding=\"async\" width=\"600\" height=\"204\" class=\"wp-image-1672\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102106.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102106.jpg 1079w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102106-300x102.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102106-1024x348.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102106-768x261.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102106-360x122.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n\n\n\n<li>Navigate to your domain&#8217;s DNS records, and add the <strong>CNAME <\/strong>you chose (e.g. <code class=\"inline-code\">img.example.com<\/code>). If you&#8217;re unsure how, please <strong>contact your hosting provider for assistance<\/strong>.\n<ul class=\"wp-block-list\">\n<li>If you want to keep using ShortPixel&#8217;s CDN, the CNAME must point to <code class=\"inline-code\">cdn.shortpixel.ai<\/code> (If you are using Cloudflare for your DNS, the record must be <strong>DNS Only<\/strong> instead of Proxied)<\/li>\n\n\n\n<li>If you want to use your own CDN, the CNAME must point to <code>no-cdn.shortpixel.ai<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Once the CNAME record has finished propagating (which may take <strong>up to 48 hours<\/strong>), you can return to your ShortPixel dashboard where you should find the subdomain added to your list of associated domains.<br><img decoding=\"async\" width=\"600\" height=\"156\" class=\"wp-image-1673\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102643.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102643.jpg 1127w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102643-300x78.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102643-1024x266.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102643-768x200.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_102643-360x94.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n\n\n\n<li><strong>Optionally<\/strong>, for increased security, you may check the box <strong>&#8220;Accept requests only from specific domains&#8221;<\/strong> and enter a comma-separated list of domains. For example, if only example.com and wonderfulshop.com should serve images from <code>img.example.com<\/code>, set it up as shown in the following screenshot:<br><img decoding=\"async\" width=\"600\" height=\"201\" class=\"wp-image-1674\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103226.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103226.jpg 1127w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103226-300x101.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103226-1024x343.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103226-768x258.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103226-360x121.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n\n\n\n<li>Change the CDN domain \/ API URL on the WordPress settings.\n<ul class=\"wp-block-list\">\n<li><strong>If you are using SPAI<\/strong>, navigate to your WordPress dashboard and go to <strong>Settings &gt; ShortPixel AI &gt; Behavior &gt; API URL<\/strong>. There, change the default URL to <code>https:\/\/img.example.com\/spai<\/code> where <code>img.example.com<\/code> is the subdomain that you&#8217;ve set up above.<br><img decoding=\"async\" width=\"600\" height=\"87\" class=\"wp-image-1675\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103803.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103803.jpg 841w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103803-300x44.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103803-768x111.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_103803-360x52.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n\n\n\n<li><strong>If you are using SPIO<\/strong>, navigate to your WordPress dashboard and go to <strong>Settings &gt; ShortPixel &gt; WebP\/AVIF &amp; CDN<\/strong> and enable the &#8220;Deliver the next generation images using the ShortPixel CDN&#8221; option. There, change the default URL to <code>https:\/\/img.example.com\/spio<\/code> where <code>img.example.com<\/code> is the subdomain that you&#8217;ve set up above.<br><img decoding=\"async\" width=\"600\" height=\"233\" class=\"wp-image-1676\" style=\"width: 600px;\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_104010.jpg\" alt=\"\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_104010.jpg 769w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_104010-300x117.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250206_104010-360x140.jpg 360w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"callout-yellow\">Please make sure you <a href=\"https:\/\/shortpixel.com\/knowledge-base\/article\/how-to-clear-wordpress-cache\/\" rel=\"noopener\">flush your website&#8217;s cache<\/a> (whichever is applicable &#8211; caching plugin, server cache, CDN cache, and browser cache).\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Important: If you are on a free plan or have purchased one-time credit packages, you will not be able to add a custom subdomain unless you use your own CDN to deliver the images instead of ShortPixel&#8217;s. Custom subdomains with ShortPixel&#8217;s CDN are exclusively available to users who have subscribed to an unlimited or monthly\/yearly [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[35,37],"glossaries":[],"doc_tag":[],"class_list":["post-875","docs","type-docs","status-publish","hentry","doc_category-shortpixel-adaptive-images","doc_category-shortpixel-image-optimizer"],"blocksy_meta":[],"year_month":"2026-04","word_count":562,"total_views":"1690","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin","author_nicename":"admin_mdli53m5","author_url":"https:\/\/kb.shortpixel.com\/author\/admin_mdli53m5\/"},"doc_category_info":[{"term_name":"ShortPixel Adaptive Images","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-adaptive-images\/"},{"term_name":"ShortPixel Image Optimizer","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-image-optimizer\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/comments?post=875"}],"version-history":[{"count":5,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/875\/revisions"}],"predecessor-version":[{"id":2056,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/875\/revisions\/2056"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=875"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=875"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}