#1
  1. Agency SEO
    SEO Chat Mastermind (5000+ posts)

    Join Date
    Aug 2008
    Location
    Florida
    Posts
    6,193
    Rep Power
    2868

    301 redirect question


    I have an issue where I need to 301 redirect the https version of a site to the http version. The site is in wordpress. The below code works in htaccess to redirect but when I check it using an SEF redirect checker it says the redirect is NOT SEF. Any ideas? (note: I am not a developer by any means, please be gentle and keep it simple)

    Options +FollowSymlinks

    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

    # BEGIN WordPress
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    </IfModule>

    credit for the code: http://stackoverflow.com/questions/3...p-via-htaccess
  2. #2
  3. Agency SEO
    SEO Chat Mastermind (5000+ posts)

    Join Date
    Aug 2008
    Location
    Florida
    Posts
    6,193
    Rep Power
    2868
    Anyone have experience redirecting an https version to the http version?
  4. #3
  5. Busting SEOChat Spammers!
    SEO Chat High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2009
    Location
    UK - Kent - Maidstone - PC!
    Posts
    3,753
    Rep Power
    1477
    I have done it with a site or two in the past, I will see if I still have the code I used because I think it was a little different from yours.
    New To SEOChat? See Here & the FAQ's

    "stupid people say stupid things, and smart people out smart each other!" SOAD
    301 Redirects | SEO Tools | Default htaccess | CuteRank
  6. #4
  7. Busting SEOChat Spammers!
    SEO Chat High Scholar (3500 - 3999 posts)

    Join Date
    Jul 2009
    Location
    UK - Kent - Maidstone - PC!
    Posts
    3,753
    Rep Power
    1477
    Try adding the following line after the "^443$" line:
    Code:
    RewriteCond %{HTTPS} =on
    So you would have:
    Code:
    RewriteCond %{SERVER_PORT} ^443$ [OR]
    RewriteCond %{HTTPS} =on
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
    Also note the [OR] at the end of the first line in that part.

    But as it goes, what you posted first should be just fine without the extra bit I added for you.

    Also you can use either of the below to make single pages stay as https:
    .htaccess (you may need to remove the "=" before the on in the above code for this bit, and this goes directly after the "=on" line):
    Code:
    RewriteCond %{REQUEST_URI} !^/secure-page.php$ [NC]
    php code to place on individual site pages:
    Code:
    <?php
    if  ( !$_SERVER['HTTPS'] )
            {
                    $host = $_SERVER['HTTP_HOST'];
                    $request_uri = $_SERVER['REQUEST_URI'];
                    $good_url = "https://" . $host . $request_uri;
    
                    header( "HTTP/1.1 301 Moved Permanently" );
                    header( "Location: $good_url" );
                    exit;
            }
    ?>
    Note this should be right at the top of the page, before any other code!

    I got this code from different source some time ago and have them all documented in a master htaccess file, so if you ever need it just give me a shout
    Last edited by NathanielB; Jan 7th, 2013 at 10:54 AM.

Similar Threads

  1. 301 redirect question
    By andyhuk in forum Search Engine Optimization
    Replies: 1
    Last Post: Mar 9th, 2009, 07:22 AM
  2. Redirect question
    By HelmFoeHammer in forum Google Optimization
    Replies: 2
    Last Post: Aug 26th, 2008, 01:53 AM
  3. Redirect Question
    By Gdscards.com in forum Search Engine Optimization
    Replies: 5
    Last Post: Aug 20th, 2007, 12:02 AM
  4. Redirect and PR question
    By sunandwind in forum Google Optimization
    Replies: 3
    Last Post: Nov 22nd, 2005, 11:40 AM
  5. Another redirect question
    By kadana in forum Google Optimization
    Replies: 6
    Last Post: Jan 23rd, 2005, 05:03 AM

IMN logo majestic logo threadwatch logo seochat tools logo