302 redirect instead of 301 after switch to HTTPS

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.janjippe.nl/$1 [R,L]

Your “old” .htaccess file at /public_html/.htaccess would appear to have the suspect 302 redirect. Without an explicit status code, the R flag defaults to a 302.

If the entire site has been moved to the /private_html folder as part of the implementation of SSL then it would seem that HTTP (port 80) is served from /public_html and HTTPS (port 443) is served from /private_html! (A bit of a strange setup as this would allow you to (accidentally) serve different content for each – which would be a bad idea.)

If this is the case then you could probably change the old /public_html/.htaccess file to simply read:

Redirect 301 / https://www.example.com/

And potentially remove the HTTP to HTTPS redirect in the /private_html/.htaccess file, since this new site (in /private_html) would seem to only be accessed over HTTPS anyway! However, it might be preferable to keep this redirect in place “just in case” there is any change in configuration.

(Note: It can be easier to first test with temporary 302 redirects since these are not cached. If an erroneous redirect is cached then it can be confusing to debug.)

Leave a Comment