What's your biggest current challenge? Have your say in Community Polls along the right column.

How can I configure HTTP 301 redirection instead of 307?

How can I configure HTTP 301 redirection instead of 307?

mohamedhamid
Shopify Partner
3 0 0

Hi,

I would like to know how to configure HTTP redirection with code 301.

 

Currently, the redirection type is 307, which means when I navigated http://mysite.com,  I will be redirected to https//mysite.com with a code 307.

I would like to configure the redirection with code 301 which is more friendly to SEO.

In general, this can be handled at the .htaccess file, but in Shopify, that's not possible.

Anyone can help?
Thanks in advance.

Replies 11 (11)

NomtechSolution
Astronaut
1245 113 154

In Shopify, you cannot directly modify the .htaccess file to configure HTTP redirection. However, you can achieve a 301 redirection by using Shopify's built-in URL redirects feature. Here's how you can do it:

  1. In your Shopify admin, go to "Online Store" -> "Navigation".
  2. Scroll down to the "URL redirects" section and click on "Manage".
  3. Click on the "Add URL redirect" button.
  4. In the "Redirect from" field, enter the old URL that you want to redirect from (e.g., http://mysite.com).
  5. In the "Redirect to" field, enter the new URL that you want to redirect to (e.g., https://mysite.com).
  6. Set the "Redirect type" to "Permanent (301)".
  7. Click on the "Save" button to create the URL redirect.
mohamedhamid
Shopify Partner
3 0 0

Thanks for the help, but the idea you mentioned doesn't work in case I need to set the redirection for the homepage because Redirect from option only accepts subpages.
Screenshot 2023-05-30 at 15.13.44.png


MikeBZ
Tourist
6 0 1

Did anyone figure this out? I am also trying to redirect all traffic from http:// to https:// for SEO reasons.

KieranR
Shopify Partner
398 34 121

Yep. No change needed because this is not an SEO issue because a 301 is already happening.

 

The 307 you may be seeing in devtools is a cached HSTS redirect.

 

This is what is happening in a diagram: 

 

KieranR_4-1718926211390.png
From: 
Website security: A vital factor to maintain - OVHcloud Blog

 

If you provide your website URL I can demonstrate this a few ways.



Part time Shopify SEO, based in NZ. Sometimes freelance outside the 9-5.

KieranR
Shopify Partner
398 34 121

Where are you seeing the HTTP307 and have you eliminated HSTS and local caching? 

 

From memory 307 that is a cached redirect code in Chrome, meaning the server is not responding with a 307, but rather Chrome is intercepting the outgoing request and serving a 'local redirect' from its in-browser cache first.

 

So there may not necessarily be a problem to fix here.

Part time Shopify SEO, based in NZ. Sometimes freelance outside the 9-5.
MikeBZ
Tourist
6 0 1

The problem is that Google Search Console says that the current type of Shopify Redirection from http: to https: is non-canonical, resulting in your root domain not being indexed by Google.

KieranR
Shopify Partner
398 34 121

Familiar with those concepts, but not that error you are describing.

 

What error in GSC are you actually seeing? Screenshot would be good.

 

Where and how are you seeing HTTP307?

Part time Shopify SEO, based in NZ. Sometimes freelance outside the 9-5.
MikeBZ
Tourist
6 0 1

Here is a screen shot. I'm not able to discern if it is a 307, but the way Shopify is redirecting my http: to https: doesn't seem to impress Google.

Google Search Console.JPG

KieranR
Shopify Partner
398 34 121

That looks normal. Only the https should be indexable.

 

A standard Shopify redirect setup will look like this: 

KieranR_0-1718742010450.png

 

Note how only one version is indexable - that is the default way Shopify does it, and it is best SEO practise too.

 

Happy to do the same check on your site if you share the domain? 

Part time Shopify SEO, based in NZ. Sometimes freelance outside the 9-5.
mohamedhamid
Shopify Partner
3 0 0

Hi KieranR,

You can see the HTTPS 307 in the network tab after visiting any Shopify site without entering the s in the http.

For example:
1- Open browser in Incognito mode
2- Visit the shop by "HTTP" only => example: http://shopify.com

You should be able to see the 307 redirect.



Screenshot 2024-06-19 at 12.10.21.png

KieranR
Shopify Partner
398 34 121

Yeah that's right, but for me - only on second reload after the redirect had been cached in that example.

 

If you see the 307 in devtools and you go one more click, open the Headers tab, it shows it's an internal redirect with no server IP, because it's being served from the client-side internal redirect cache.

KieranR_0-1718794220188.png

 

This is not a redirect that Googlebot sees from the server response. Server is sending a 301 response every time.

Part time Shopify SEO, based in NZ. Sometimes freelance outside the 9-5.