Forum

Thread tagged as: Question, Configuration

force_ssl() using 302 redirect

PerchSystem::force_ssl(); is using a 302 (temporary) redirect. In this article, under the 'Best practices when using HTTPS' section, Google states "Redirect your users and search engines to the HTTPS page or resource with server-side 301 HTTP redirects." So, it appears a 301 would be preferred, for SEO purposes. Is it possible to change this behavior in Perch? If not, could the option be added in a future release?

Shane Lenzen

Shane Lenzen 18 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's not, but you should probably be all SSL these days anyway. Do you need to switch around?

I'm thinking more about users who don't specify 'https://' when entering a URL into their browser. Considering the tech comfort level of most people I interact with on a daily basis, I'm going to assume that's the majority. I mean, when I go to google.com, I don't type 'https://www.google.com'...I just type 'google.com'.

EDIT: That would include tweets, links in blogs, etc. If someone links https:// instead of https:// by accident, I want it to 301, not 302. I can't think of a scenario where I would want a 302, really.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Right - you should probably be doing that way before the request hits your CMS.

Yes, I'm doing it with .htaccess now. In case anyone is curious:

# Force HTTPS
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} domain.com [NC]
  RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]

I just thought it might be good for Perch to use a 301, too, in case someone wanted to use this functionality rather than .htaccess. So, I came to the forum like a productive member of the Perch society.