Problem/Motivation

The module always use 302 code for redirect https to http url. For different cases needed return 301 code. It's also will be better for google/bing/yandex.

Proposed resolution

Change securepages_goto() for use new variable "securepages_code" for redirect instead 302 code always. The variable can be change on module administration page.

User interface changes

Securepages administration page have new option "Redirect HTTP Code" with two values "301 Moved Permanently" and "302 Found".

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

spleshka’s picture

Title: The HTTP response Code of performing URL redirection » Possibility to change HTTP response code of the URL redirect
Component: User interface » Code
Category: Bug report » Feature request
Priority: Major » Normal
Status: Needs review » Needs work
Issue tags: -Drupal SEO +SEO

First of all I think this is not a bug report but a feature request - module may work without this patch correctly. Also this issue is not major, because it doesn't add something incredibly important to the module. So I have changed these fields.

Now about your patch:

1.

+++ b/securepages.module
@@ -200,9 +200,14 @@ function securepages_goto($secure) {
+    }else{
+      $code = '301 Moved Permanently';
+    }

This doesn't match Drupal coding standards - else should be on a next line after closing bracer.

2. If you have introduced a new variable - you have to add it to the hook_uninstall() section as well.

3.

+++ b/securepages.admin.inc
@@ -19,6 +19,18 @@ function securepages_settings($form, &$form_state) {
+    '#description' => t('The HTTP response status code of performing URL redirection.'),

I think, better to rename it to "HTTP response status code of the URL redirect.". Otherwise this description is hard to understand.

m@ster’s picture

Assigned: m@ster » Unassigned
StatusFileSize
new2.23 KB

thank you, fixed

m@ster’s picture

Status: Needs work » Needs review
spleshka’s picture

Status: Needs review » Needs work
+++ b/securepages.module
@@ -200,9 +200,15 @@ function securepages_goto($secure) {
+    else{

Again wrong coding standards :) You should have a space after "else".

m@ster’s picture

Status: Needs work » Needs review
StatusFileSize
new2.23 KB

fixed

spleshka’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Rusland, now patch looks good! I've also tested it on simplytest.me - works as expected. So now we are waiting to commit this patch.

loparev’s picture

+1

@gordon, do you have plans to commit this patch?

peter.thorndycraft’s picture

Just wanted to add our experience which this patch:

We were experiencing cron and timeout issues on the site and the root problem was that 302 redirects, caused by some pages being secured, were causing cron tasks to not complete properly. Applying this patch fixed the problem.

modulist’s picture

rusl@n's patch in #5 worked beautifully for us. However, we missed the part about the affordance in the Drupal admin UI, that lets you toggle between 302 Found and 301 Moved Permanently redirect codes at /admin/config/system/securepages

If you're fairly confident in your new HTTPS setup, you will want to use the 301 Moved Permanently code. Having a 302 Found code will be detrimental to the authority of your SEO rankings as the search engines will consider your new pages temporary.

Another way to toggle the variable is through drush:

drush vset securepages_code 301

Hopefully this comment will save someone else hours of grief by making the same silly mistake we did!

VanD’s picture

I'd like to see this committed to the module as well.

philosurfer’s picture

Please commit today! One less patch to manage please. :^D

rahul.nahar001’s picture

It's working fine on my site.
@gordon, do you have plans to commit this patch?

astonvictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Reviewed & tested by the community » Fixed

finally merged a new MR.
thanks all.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.