• Resolved Niwa

    (@laniwa)


    I am pulling my hair out with this issue. We recently got an SSL certificate and I am working on making sure all URLs with http redirect to https.

    This is my current .htaccess code:

    # 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]
    </IfModule>
    
    # END WordPress

    When I add this code however:

    <IfModule mod_rewrite.c>
    # BEGIN Force http to https
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R=301,L]
    # END Force http to https
    </IfModule>
    
    # 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]
    </IfModule>
    # END WordPress

    because my WordPress install is in a subfolder it breaks and tries to change my urls to https://www.mysite.com/subfolder/restoflink

    Is there any way to fix this??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Niwa

    (@laniwa)

    I can’t seem to edit my previous post, but currently I have changed my code to be this:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    # 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]
    </IfModule>
    # END WordPress

    Feel free to look at the site to see it in action: https://www.grandcanyonplanning.com

    The WEIRD thing is that when there is a child page such as https://grandcanyonplanning.com/services/estate-planning/

    it redirects it to https://grandcanyonplanning.com/gcpa/services/estate-planning/ which is not valid (notice the gcpa/ subfolder appears)

    but https://grandcanyonplanning.com/services/estate-planning/ works just fine!

    Weirdly enough this only affects those child pages and I am not sure HOW to fix this!

    • This reply was modified 8 years, 4 months ago by Niwa.

    I feel it has to do with your first RewriteRule, have you tried putting the URL in?

    I would take a look at this page here: Force HTTPS via HTAccess

    Thread Starter Niwa

    (@laniwa)

    Thanks for your reply. I have changed the code to this following that page:

    RewriteEngine On 
    RewriteCond %{HTTP_HOST} ^grandcanyonplanning\.com [NC]
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://grandcanyonplanning/$1 [R,L]
    
    # 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]
    </IfModule>
    # END WordPress

    and I am still having the same issue.

    Are you missing the .com on this line?
    [code]RewriteRule ^(.*)$ https://grandcanyonplanning/$1 [R,L][/code]

    What is the site url and home url in your WP Options?

    Thread Starter Niwa

    (@laniwa)

    RESOLVED

    This is probably the dumbest solution but I figured out the issue. since I have the WordPress installation in a subfolder, I had some conflicting redirects in the .htaccess on the root directory.

    I was not aware that the WordPress htaccess needed to be just in the folder and not on the root. Once I removed that from the root everything started working just fine.

    • This reply was modified 8 years, 4 months ago by Niwa.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘http to https – WP in Subfolder issues’ is closed to new replies.