How can I redirect my subdomain to a specific page?

How can I redirect my subdomain to a specific page?

GScreative
Tourist
5 0 4

I currently have the subdomain: pufferhug.com and would that url to link to a different page (that's created on shopify). I know shopify allows redirects for internal links, though this feature didn't have anything for my specific case.

 

Is this something that's possible? If so, what's the best way to redirect?

 

Thanks!

Replies 24 (24)

Ollie
Shopify Staff
2550 460 420

Hey @GScreative.

Thanks for reaching out.

I appreciate that you have let us know which domain you are using. For all domains that are connected to Shopify, they are connected to the entire Shopify account rather than a page or collection in particular. There are pages and collections for your website that are created within your account, but the domains are connected with the account in general. For that reason, there isn't a way to connect the subdomain to a specific product or collection page on its own.

I can definitely see how this would be beneficial to allow on the platform and I can provide this as a suggestion to our developers. With that being said, you're able to adjust the last part of the collection or product domain to whatever you like.

As an example, if your collection is called "Cool Shades" and you wanted the URL to say something like "Sun Glasses" you could change it from www.yourdomain.com/collection/coolshades to www.yourdomain.com/collection/sunglasses. In order to do that you can go into your collection directly and click on the SEO editor at the bottom of the page. I took a screenshot from my test store to show you the section I am referring to:

24-43-47478-72203

Once you select on Edit SEO, you should then be able to add a custom end of the URL.

24-44-72388-44372

Looking forward to your reply, let me know if you have any additional questions.

Ollie | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

GScreative
Tourist
5 0 4

Thanks for your response. We want the url of "pufferhug.com"  to redirect to a different page. So when that url is entered, it takes them to another page instead of 'pufferhug.com'.

GScreative
Tourist
5 0 4

Hello @Ollie 

Thanks for the response! We want the url of "pufferhug.com"  to redirect to a different page. So when that url is entered, it takes them to another page instead of 'pufferhug.com'. This other page is a page hosted by Shopify.

We want our homepage of “pufferhug.com” to forward/redirect to a different landing page we created for a faux-store front.

Fenrirme
Tourist
4 0 0

I am also requesting this feature

Oreoeater93
Visitor
2 0 0

I'd like to request this feature as well if Shopify can figure out a way to have the Alias Domain redirect to a specific page 🙂

drmlvv
Shopify Partner
5 0 3
You can with a page rule. Do you use cloudflare?

You must create a AAAA record for the subdomain and give it a value of “100::” without the quotes. Then create a redirect rule and forward that subdomain to the page URL you want. Took me a while to figure this out as well.

Good luck.



drmlvv
Shopify Partner
5 0 3

To further clarify my post above, you must set this up in your DNS hosting provider (usually that's the same as your domain registrar, but not always, ie GoDaddy, CloudFlare, etc.).   You must first create a placeholder DNS AAAA record for that specific subdomain with the value of "100::".  (see first screenshot).   

Then create a Redirect Rule to send the subdomain traffic to a page URL (see second screenshot).

In my examples, I am sending buy.dermeleve.com to a specific product page within our store that also applies an automatic discount. (https://dermeleve.com/discount/NEWPATIENT?redirect=/products/dermeleve%C2%AE-cream)

 

This cannot be done for a subdomain in Shopify's redirects; only pages after the .com (for example domain.com/*from-here*. to domain.com/*to-wherever-you-want-here*.   

 

Hope that's helpful!

 

Screenshot 2024-02-24 at 3.44.18 PM.pngScreenshot 2024-02-24 at 3.43.23 PM.png

drmlvv
Shopify Partner
5 0 3

I'd like to request this feature too.  We want to point a subdomain to a specific page in our store.   for example we want to point "promo.xxxxxxxx.com" to xxxxxxxxx.com/pages/promo. Or buy.xxxxxxx.com to xxxxxxx.com/pages/whatever

 

Setting up Forwarding URLs in CloudFlare doesn't seem to work.  Also setting up their new Redirect Rules doesn't work either.

 

Does Shopify somehow block these?

andgamb
Shopify Partner
8 0 6

Hi - you can make it work with a little javascript.

Add your Subdomain as a single domain to Shopify Domains. There choose "Alias for Domain" (third option).

 

Now in your theme.liquid in the header do the following:

<script>
    if(document.location.href.indexOf('testthis') > -1) { 
        document.location.href = 'http://www.test.com';
    }
</script>

just change "testthis" to whatever your special subdomain or domain part is. Then change www.test.com to the url you want to forward to.

 

I know it is not just configurativ and it would actually be nice if Shopify's forwarding system would allow to choose the domain base path as startingpoint uf a forward instead of just the path

but nevertheless it's maintainable by yourself without the need to spin up a proxy

duneboarder
Visitor
2 0 1

This works great!

 

EXCEPT I'm running into one issue. Not only is it forwarding my subdomain, it's also forwarding a page I have set up with the same name. To be specific:

I wanted to forward https://warranty.whisperearcare.com to a Tally form to collect data. This is working great!

However, this page is also being forwarded to the same place https://whisperearcare.com/pages/warranty

Is there any way to ONLY forward to subdomain, but leave the page above without any url forwarding?



andgamb
Shopify Partner
8 0 6

You can focus on the domain specifically. The above example was more a "search" within your location. If you change it to the following it's more explicit:

 

<script>
    var host = window.location.host;
    var sub = host.split('.')[0];
	if(sub == 'testthis') { 
        document.location.href = 'http://www.test.com';
    }
</script>

So you check the host, then take the first part and if that matches your "searchword" you do the forward. 

 

Pay attention - if your domain is something like my.warranty.yourdomain.com then the script above would give you "my" as the first part. e.g. you need to change your split to [1] to give you "warranty" as your searchword.

duneboarder
Visitor
2 0 1

THANK YOU!

 

Now my problem is totally solved. Really appreciate your help 🙂

Fenrirme
Tourist
4 0 0

wait so i can add this to the back end and get a second url with an ssl (https://dc20.com) to redirect to the page we need it to go to (https://thedungeongcoach.com/dc20 )?

andgamb
Shopify Partner
8 0 6

In that case it's a second domain dc20.com ? You can specifiy a forward directly at your hoster. 

if you want to do it with javascript you would need to use the first script which looks for dc20.com

i would adapt it to just look at the host instead of the full href. because else the script would also trigger on the subpage and you would have a redirect loop

 

<script>
    if(document.location.host.indexOf('dc20.com') > -1) { 
        document.location.href = 'https://thedungeongcoach.com/dc20';
    }
</script>

 

brazeranch
Tourist
3 0 2

I can't seem to get this to work. Am I doing something wrong? Added the code to the theme.liquid header. I need waldocropmaze.com to redirect to brazeranch.com/pages/cropmaze

 

Screenshot 2024-02-22 at 10.20.35 AM.pngScreenshot 2024-02-22 at 10.17.50 AM.png

drmlvv
Shopify Partner
5 0 3

I'm curious would this exact script also work if someone visited  waldocropmaze.brazeranch.com ?

andgamb
Shopify Partner
8 0 6

as "waldocropmaze" is the subdomain it would work as theme.liquid is the same. as long as you search in the href. 

 

again see https://github.com/nirjan-dev/learning-to-code/issues/370 for a clear image of URL parts

andgamb
Shopify Partner
8 0 6

In that case you have a domain and not a subdomain. like subdomain.waldocropmaze.com you would need to use the first script:


Check https://github.com/nirjan-dev/learning-to-code/issues/370 for help. As you have a domain only I would specifically search in the host part

 

<script>
    if(document.location.host.indexOf('waldocropmaze.com') > -1) { 
        document.location.href = 'http://www.brazeranch.com/pages/cropmaze';
    }
</script>
brazeranch
Tourist
3 0 2

Oh my goodness. You get the "most amazing human being" award today. Thank you!!!!

Joey_V
Tourist
3 0 1

@andgamb nice work!

 

Would we need to copy paste this multiple times, if, for example, we had 12 sub-domains, redirecting to 12 specific collection pages?

andgamb
Shopify Partner
8 0 6

In that case I would suggest looking into the Switch Statement: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch?retiredLocale=de 

it would look something like this, just add all your cases:

 

<script>
    var host = window.location.host;
    var sub = host.split('.')[0];
       switch (sub) {
          case 'SUBDOMAIN1':
            document.location.href = 'http://www.test.com';
            break;
          case 'SUBDOMAIN2':
            document.location.href = 'http://www.test2.com';
            break;
          default:
            document.location.href = 'http://www.default.com';
       }
</script>

 

just written that down - completely untested! 

Kaimok
Excursionist
24 0 1

Hi,

I'm experiencing the same issue and tried following your steps, but I think I might be doing something wrong. The subdomain is still directing to the home page instead of the specific page I want.

The subdomain is: www.beauty.kaimok.com

The page I want to redirect to: https://www.kaimok.com/pages/beauty

 

Captura de pantalla 2024-08-14 003255.pngCaptura de pantalla 2024-08-14 003431.png

 

Additionally, the URL now looks different with the subdomain.

 

 

Captura de pantalla 2024-08-14 003326.png

 

What can I do to fix this?

drmlvv
Shopify Partner
5 0 3
Kaimok
Excursionist
24 0 1

Thanks, I have tried on Shopify domain page, but it doesn't work.
It always goes to the main page.
Should I put the subdomain as Alias?
What about the DNS?
Captura de pantalla 2024-08-14 095453.png

thanks