Great community. Great ideas.

Welcome to SEOChat, a community dedicated to helping beginners and professionals alike in improving their Search Engine Optimization knowledge.  Sign up today to gain access to the combined insight of tens of thousands of members.

  1. May 16th, 2013
    Views:
    389

Thread: 301 redirect question

Results 1 to 4 of 4
Share This Thread →
  1. #1
    KernelPanic's Avatar
    KernelPanic is offline SEO Gun for Hire SEO Chat Mastermind (5000+ posts)
    Join Date
    Aug 2008
    Location
    Florida
    Posts
    5,066
    Rep Power
    2559

    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
    SEO is 50% muscle, 50% luck and all the rest is my brain hard at work in Orlando
    Dedicated SEO Staff in Orlando FL

  2. #2
    KernelPanic's Avatar
    KernelPanic is offline SEO Gun for Hire SEO Chat Mastermind (5000+ posts)
    Join Date
    Aug 2008
    Location
    Florida
    Posts
    5,066
    Rep Power
    2559
    Anyone have experience redirecting an https version to the http version?

  3. #3
    NathanielB's Avatar
    NathanielB is offline Busting SEOChat Spammers! SEO Chat High Scholar (3500 - 3999 posts)
    Join Date
    Jul 2009
    Location
    UK - Kent - Maidstone - PC!
    Posts
    3,528
    Rep Power
    1367
    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

  4. #4
    NathanielB's Avatar
    NathanielB is offline Busting SEOChat Spammers! SEO Chat High Scholar (3500 - 3999 posts)
    Join Date
    Jul 2009
    Location
    UK - Kent - Maidstone - PC!
    Posts
    3,528
    Rep Power
    1367
    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 09:54 AM.

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

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

SEO Chat Advertisers and Affiliates