How to change 302 redirect from http to https
-
Hi gang. Our site currently has a 302 redirect from the HTTP version of the homepage to the HTTPS version of the homepage. I understand this really should be changed to a 301 redirect but I'm having a little trouble figuring out exactly how this should be done.
Some places on the internet are telling me I can edit our htaccess file to specify the type of redirect, however our htaccess file seems to be missing some of the information in theirs.
Can anyone tell me what needs to be changed in the htaccess file - or if there's a simpler way to change the 302 to a 301? Many thanks
htaccess:
BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
END WordPress
EXPIRES CACHING
ExpiresActive On
ExpiresByType image/jpg "access plus 6 months"
ExpiresByType image/jpeg "access plus 6 months"
ExpiresByType image/gif "access plus 6 months"
ExpiresByType image/png "access plus 6 months"
ExpiresByType text/css "access plus 10 days"
ExpiresByType application/pdf "access plus 10 days"
ExpiresByType application/x-shockwave-flash "access plus 10 days"
ExpiresByType image/x-icon "access plus 6 months"
ExpiresDefault "access plus 2 days"
EXPIRES CACHING
-
Oop hi Ikkie, thanks for responding and sorry I didn't. Been one of those weeks!
When I tried this I got the following error: 'www.midlandnetworks.co.uk redirected you too many times.' Do I need to replace the first bit of my htaccess with that or just stick it on the end? Sticking on the end didn't seem too successful for me.
-
Hi David! Did Ikkie's response do the trick?
-
Hi Use the following
`# Redirect all "not correct" domain to www with https # (is not important if comes with or without https): RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC] RewriteRule ^(.*)$ https://www.example.co.uk/$1 [L,R=301] # Redirect all non-ssl to ssl. RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R,L]`
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
I have a question about the impact of a root domain redirect on site-wide redirects and slugs.
I have a question about the impact (if any) of site-wide redirects for DNS/hosting change purposes. I am preparing to redirect the domain for a site I manage from https://siteImanage.com to https://www.siteImanage.com. Traffic to the site currently redirects in reverse, from https://www.siteImanage.com to https://siteImanage.com. Based on my research, I understand that making this change should not affect the site’s excellent SEO as long as my canonical tags are updated and a 301 redirect is in place. But I wanted to make sure there wasn’t a potential consequence of this switch I’m not considering. Because this redirect lives at the root of all the site’s slugs and existing redirects, will it technically produce a redirect chain or a redirect loop? If it does, is that problematic? Thanks for your input!
Technical SEO | | mollykathariner_ms0 -
How to resolve warning of pages with redirect chain when its your http:// to https://www.
how do I write a 301 redirect in the htaccess file so that http:// goes straight to https://www. Moz replyEli profileHey there!Thanks for reaching out to us!
Technical SEO | | VelocityWebsites0 -
Http v https Duplicate Issues
Hello, I noticed earlier an issue on my site. http://mysite.com and https://mysite.com both had canonical links pointing to themselves so in effect creating duplicate content. I have now taken steps to ensure the https version has a canonical that points to the http version but I was wondering what other steps would people recommend? Is it safe to NOINDEX the https pages? Or block them via robots.txt or both? We are not quite ready to go fully HTTPS with our site yet (I know Google now prefers this) Any thoughts would be very much appreciated.
Technical SEO | | niallfred0 -
Pro's & contra's: http vs https
Hi there, We are planning to take the step and go from http to https. The main reason to do this, is to mean trustfull to our clients. And of course the rumours that it would be better for ranking (in the future). We have a large e-commerce site. A part of this site ia already HTTPS. I've read a lot of info about pro's and contra's, also this MOZ article: http://moz.com/blog/seo-tips-https-ssl
Technical SEO | | Leonie-Kramer
But i want to know some experience from others who already done this. What did you encountered when changing to HTTPS, did you had ranking drops, or loss of links etc? I want to make a list form pro's and contra's and things we have to do in advance. Thanx, Leonie0 -
Switching to HTTPS from HTTP
Hi, I have switched my website from http to https but now I my facing a problem when I type URL with www ( e.g https://www.example.com) in browser that is working fine but when I type URL without www like https://example.com "This connection is untrusted" error is showing . All I want to is redirect https://example.com to https://www.example.com. Please let me know how can I redirect? Thanks
Technical SEO | | Alick3000 -
Delete 301 redirected pages from server after redirect is in place?
Should I remove the redirected old pages from my site after the redirects are in place? Google is hating the redirects and we have tanked. I did over 50 redirects this week, consolidating content and making one great page our of 3-10 pages with very little content per page. But the old pages are still visible to google's bot. Also, I have not put a rel canonical to itself on the new pages. Is that necessary? Thanks! Jean
Technical SEO | | JeanYates0 -
Best method of redirecting http to https on homepage
Hi everyone, I'm looking to redirect all http requests to https for a site's homepage. It only needs to be for the homepage, not site wide. What's the best method of doing this without losing pagerank or ranking? I'm using IIS7.5 so I've been looking at a URL Rewrite or possibly this ASP.Net solution; http://www.xdevsoftware.com/blog/post/Redirect-from-Http-to-Https-in-ASPNET.aspx Or is a simple 301 or 302 (for some reason Microsoft's site says to do a 302 re-direct, though I'm not sure if this is great from an SEO perspective?) re-direct from http version to the https version the best method? Also if the solution retained the URL query string that would be even better! Any help appreciated! Thanks
Technical SEO | | PeterAlexLeigh0