I checked the header status of the redirect with the following tool
http://www.seoconsultants.com/tools/headers.asp
and noticed its response was 302 redirect.

I think using a 301 redirect would be a better choice. Thought?
http://www.bigoakinc.com/blog/when-to-use-a-301-vs-302-redirect/
http://www.mattcutts.com/blog/seo-advice-discussing-302-redirects/

I have included a patch to make the necessary change.

I dont know why anyone would want this redirect to be a 302 but if there is a use-case we could include a admin setting to switch between 301 and 302 redirects. Thoughts?

Comments

mrfelton’s picture

I agree that a 301 seems more appropriate. no?

hass’s picture

Status: Active » Needs work

Use API functions for "header" in Drupal, please. See http://api.drupal.org/api/function/drupal_set_header/6

mjpa’s picture

I personally feel this issue is only related to changing the redirect to a 301 (which the patch does fine), the module uses header() in quite a few places and changing to drupal_set_header() should be a separat issue

scottystang’s picture

I think I have the same problem in that requests to http://mysite.com are using 302 redirects to https://mysite.com instead of 301.

How do I fix this? My .htaccess and httpd.conf files are using 301 redirects properly, but I think the issue I'm having is with the Drupal core files/functions. I can't find the module that is specified above.

dave kopecek’s picture

The patch works for me. It would be great if this could be rolled into 6.x-1.x

matthand’s picture

Priority: Normal » Critical

Has this been committed? It should be. A 302 redirect is NOT recognized by Google for their search ranking. If you use this module without this patch your site will virtually disappear from Google searches.

dpearcefl’s picture

I agree. Can we get this patch included?

grendzy’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Priority: Critical » Normal

If you use this module without this patch your site will virtually disappear from Google searches.

That's an extraordinary claim, and is contrary to the citations provided by the OP (as well as personal experience).

The situation is a little more complicated now that the redirect can vary depending on a user's role, so in many cases a 302 is more correct.

Probably the simplest solution is to add a radio button for 301/302, that would also enable custom modules to add more fancy logic by fiddling with the global $conf.

scott m. sanders’s picture

It seems true though that if you move to HTTPS from HTTP and Secure Pages does a 302 instead of 301 that your existing Google, Bing, etc. results of HTTP will not automatically go to its HTTPS equivalent and thus will diminish quickly -- though they should rebuild after a while, but the whole point of using a proper 301 redirect is to keep them. (I am no fan of "SEO," but this seems to be the case.)

I was just shown this myself on one of my sites. Luckily there is a patch, but I may be a bit late.

scott m. sanders’s picture

techypaul’s picture

Just FYI: With regards to #8, our entire site was removed by google after this (we force use ssl across the site). We are back up after making the changes required as per the patch.

roderik’s picture

Status: Needs work » Needs review

The patch in this issue was still for D6, though the status says D7.

Here's a D7 patch with an admin screen, as was hinted at in the original issue summary. It's because I want to be able to switch things back immediately if strange problems arise, but may be useful for people with special needs. (I don't know of them.)

I kept the default behavior the same (sending a 302) out of fear of breaking existing sites on upgrade. Please discuss the sense in this, and check the wording in the settings page. Thanks.

hanoii’s picture

Issue summary: View changes
StatusFileSize
new757 bytes

@roderik apparently forgot to upload a patch, which I am doing right now. I do believe 301 is the way to go mainly for SEO reasons and because it makes more sense to have a 301 instead of a 302.

john franklin’s picture

StatusFileSize
new908 bytes

A version of the D6 patch that uses drupal_set_header() in both the securepages_goto() function and the admin/build/securepages/test handler.

davidwbarratt’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2381857: Possibility to change HTTP response code of the URL redirect

I think #2381857: Possibility to change HTTP response code of the URL redirect is probably a better solution since it's user configurable.