Warning about a 302 redirect
-
Hello everyone,
I'm testing the pro software and recently I installed an SSL Certificate on one of the websites I'm monitoring, I put in place an .htaccess directive to force all traffic to the secure version of the site (https) and I noticed how this raised a warning because my directive is forcing the traffic with a 302 redirect.
These are the lines:
_RewriteCond %{SERVER_PORT} 80 _
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
I understand that this is not good so I figured since I'm already redirecting all www to -www I can force traffic that arrives trying to use www to the secure version like so:
RewriteCond %{HTTP_HOST} !^example.com$
RewriteRule (.*) https://example.com/$1 [R=301,L]
But this is not 100% effective because if someone visits the site directly on the -www version this person wont get redirected hence it wont be forced to see the https.
So my question is: does anybody know of an alternate way to force traffic to the secure socket using a 301 instead of a 302?
Oh boy, just by writing the question I think I may have figured it out, I'll post it anyways because (1) I could be wrong and (2) It could help someone else.
It just hit me but the directive that is forcing www to -www specifies what type of redirect to do here [R=301,L].
So to try to answer my own question before even posting it this could probably do the trick:
_RewriteCond %{SERVER_PORT} 80 _
_RewriteRule ^(.*)$ https://example.com/$1 [_R=301,R,L]
I'll be testing it out ASAP and again I'll post the question anyways just in case it doesn't work, in case someone has a good suggestion or to help someone that could be in the same situation.
If this is turns out right I will need someone to slap me in the face
-
Hi Steven,
Don't you just love that moment when you realize that you were clever enough to figure out the answer without help from anyone else?
Very nice of you to "take one for the team" by leaving the post to help others who might follow in your footsteps
Sha
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
-
Redirects Being Removed...
Hi We have a team in France who deal with the backend of the site, only problem is it's not always SEO friendly. I have lots of 404's showing in webmaster tools and I know some of them have previously had redirects. If we update a URL on the site, any links pointing to it on the website are updated straight away to point to the most up to date URL - so the user doesn't have to go through a redirect. However, the team would see this as the redirect not being 'used' after about 30 days and remove it from the database - so this URL no longer has any redirects pointing to it. My question is, surely this is bad for SEO? However I'm a little unsure as they aren't actually going through the redirect. But somewhere in cyber space the authority of this page must drop? Any advice is welcome 🙂
Intermediate & Advanced SEO | | BeckyKey0 -
Best Approach to Redirect One Domain to Another
So I'm about to migrate one domain to another. Lets say I'm migrating boo.com to foo.com. Boo.com has good organic traffic & has some really well ranked pages. For this reason (I think) I want to send that traffic to some where other than the foo.com homepage. Perhaps a catered landing page. My question is can I redirect some of the specific pages on boo.com to a landing page on foo.com & then redirect the delta to foo.com's homepage? Or am a risking not fully transferring the full credit of one domain to another if I take that approach & therefore I should just redirect one domain to the other in its entirety? Thanks, Rich
Intermediate & Advanced SEO | | RPD0 -
302 Redirect of www. version of a site - Pros/Cons
Hi, I am considering making the 301 redirect from the domain to a 302 temporary redirect. Currently if a user lands on "www" version of the site, they are redirected to the non "www" version. But after the redirect, they will land on an external webpage (so if a user lands on the "www" version, they are redirected to a different website, not related to my domain). Reason I'm considering this is because I have received a large number of spammy backlinks on the "www" version of the site (negative seo). So I'm hoping that the temporary redirect will help me recover. Your thoughts on this: 1. Is this the best way to do a 302 redirect (redirecting the www version to an external domain)? 2. Will the redirect help the main domain recover, considering all spammy backlinks are pointing to the www version? 3. What are the pros/cons, if any? Thanks in advance for your thoughts! Howard
Intermediate & Advanced SEO | | howardd0 -
301 redirect with /? in URL
For a Wordpress site that has the ending / in the URL with a ? after it... how can you do a 301 redirect to strip off anything after the / For example how to take this URL domain.com/article-name/?utm_source=feedburner and 301 to this URL domain.com/article-name/ Thank you for the help
Intermediate & Advanced SEO | | COEDMediaGroup0 -
Google penalized site--307/302 redirect to new site-- Via intermediate link—New Site Ranking Gone..?
Hi, I have a site that google had placed a manual link penalty on, let’s call this our
Intermediate & Advanced SEO | | Robdob2013
company site. We tried and tried to get the penalty removed, and finally gave up and purchased another name. It was our understanding that we could safely use either a 302 or 307 temporary redirect in order to redirect people from our old domain to our new one.. We put this into place several months and everything seemed to be going along well. Several days ago I noticed that our root domain name had dropped for our selected keyword from position 9 to position 65. Upon looking into our GWT under “Links to Your site” , I have found many, many, many links which were pointed to our old google penalized domain name to our new root domain name each of this links had a sub heading “Via this intermediate link -> Our Old Domain Google Penalized Domain Name” In light of all of this going on, I have removed the 307/302 redirect, have brought the
old penalized site back which now consists of a basic “we’ve moved page” which is linked to our new site using a rel=’nofollow’ I am hoping that -1- Our new domain has probably not received a manual penalty and is most likely now
received some sort of algorithmic penalty, and that as these “intermediate links” will soon disappear because I’m no longer doing the 302/307 from the old sight to the new. Do you think this is the case now or that I now have a new manual penalty place on the new
domain name.. I would very much appreciate any comments and/or suggestions as to what I should or can do to get this fixed. I need to still keep the old domain name as this address has already been printed on business cards many, many years ago.. Also on a side note some of the sub pages of the new root domain are still ranking very
well, it’s only the root domain that is now racking awfully.. Thanks,0 -
301 redirect or rel=canonical
On my site, which I created with Joomla, there seems to be a lot of duplicated pages. I was wondering which would be better, 301 redirect or rel=canonical. On SeoMoz Pro "help" they suggest only the rel=canonical and dont mention 301 redirect. However, ive read many other say that 301 redirect should be the number one option. Also, does 301 redirect help solve the crawling errors, in other words, does it get rid of the errors of "duplicate page content?" Ive read that re-=canonical does not right? Thanks!
Intermediate & Advanced SEO | | waltergah0 -
301 redirects and Blogger - moving blog
Is there any way to add 301 redirects to individual posts on a blogger-hosted blog? We're getting ready to finally move our blog off of Blogger and onto our own webserver. We're probably going to use BlogEngine.net to run it. right now the blog is located at blog.MySite.com. We're probably going to move it to MySite.com/Blog. We don't have any really popular posts and we only really get ~10 visits a day on about 70 posts. Just trying to figure out the best way to handle this without inadvertently shooting myself in the foot.
Intermediate & Advanced SEO | | _JP_0 -
301 Redirects After Company Acquisition
We recently acquired a company, and now we are going to redirect all of the pages on their site to their respective pages on our site. Do we need to keep the original pages on their site active? For how long? Ideally, we would like to redirect everything and remove the old site entirely so we don't have to pay to keep hosting it. Is this possible? Thanks!
Intermediate & Advanced SEO | | pbhatt1