Submit Your Article Forum Rules

Results 1 to 2 of 2

Thread: Issue with a http / https redirect

  1. #1
    Member julien_simon's Avatar
    Join Date
    Dec 2010
    Location
    Vancouver
    Posts
    76

    Question Issue with a http / https redirect

    Hi guys,

    I am pulling my hair with this redirect issue and hope you guys can shed some light on this.

    Situation: Just took over a site that was switched to WP from aspx on April 1st. One of the issue of the site is that is has both http and https versions competing for the same content. The site has about 380 pages and Google has indexed about half under http and the other half under https. For consistency sake and to prevent duplicate content issue, I want the site to display http except for the couple of pages that actually need encryption.

    I tried 2 or 3 different rules but none of them work completely. The closest I've got is that the home page of https now redirects but none of the inner pages do. Here is the top of my HTaccess file:

    # BEGIN wordpress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    RewriteCond %{HTTPS} =on
    RewriteRule ^(.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    </IfModule>

    # END wordpress

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.pardonservicescanada.com$ [NC]
    RewriteRule ^(.*)$ http://pardonservicescanada.com/$1 [R=301,L]


    RewriteEngine On
    RewriteCond %{HTTPS} =on
    RewriteRule ^(.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    I've tried using:
    RewriteEngine On
    RewriteCond %{HTTPS} =on
    RewriteRule ^(.*) http://%{SERVER_NAME}/$1 [R=301,L]
    as well as
    http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    instead of
    {HTTP_HOST}%{REQUEST_URI}
    but same results.

    Two weird things:

    1) If I remove
    # BEGIN wordpress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    RewriteCond %{HTTPS} =on
    RewriteRule ^(.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    </IfModule>

    # END wordpress

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.pardonservicescanada.com$ [NC]
    RewriteRule ^(.*)$ http://pardonservicescanada.com/$1 [R=301,L]
    The https rule works for inner pages but the http pages can't load anymore.


    2) If I remove the entire content of the htaccess

    The www to non www and index.php to / redirects still work. There is also no robots.txt file in the root folder but I can see one online. When I add my own, it changes the one that online.

    Anyway, I've spent the whole afternoon and most of the morning on this issue and no luck so far.

    Any ideas please?

  2. #2
    Member julien_simon's Avatar
    Join Date
    Dec 2010
    Location
    Vancouver
    Posts
    76
    Update: The issue is fixed. By simply reordering things within the htaccess file, we manage to fix the issue. WP was interfering with the rule which had to be placed above the code like this:


    Options +FollowSymlinks


    <IfModule mod_rewrite.c>
    RewriteEngine On

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

    # BEGIN wordpress
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END wordpress
    </IfModule>


    # protect wpconfig at all cost
    <files wp-config.php>
    Order deny,allow
    deny from all
    </files>


    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.pardonservicescanada.com$ [NC]
    RewriteRule ^(.*)$ http://pardonservicescanada.com/$1 [R=301,L]
    So simple yet so annoying

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •