• Hi! Im runing WordPress in a subfolder, so I have a htaccess and index.php file in my root directory, and WP in a subfolder.
    What I would like to do is switch my site over to SSL. WordPress is already running with https as the site adress, but it is still possible to go to the http version of the site.
    So what I have to do, I have to force everything and everybody accessing the http version of the blog over to the https version. There′s lots of info on this on the web, and it says you should use htaccess and adding these lines at the very top (before the wordpress entries):

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
    RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

    Ok, my short question after long description: Am I okay by simple inserting this, or do I have to modify things because WP is residing in a subdirectory? I think it should work… but its really difficult for me to wrap my mind around htaccess rules.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Pepz345

    (@pepz345)

    Just to add how things would look like… this is my current htaccess in the webserver root:

    # 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

    This is the standard htaccess file which WP creates, I think.
    After modification, it would direct everything with http over to https and look like this:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
    RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]
    # 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

    Does this look right? And should I put it into the WP subfolder also, or wouldnt it matter there anyway?

    You can try this:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need to setup a https redirect to WP in a subfolder’ is closed to new replies.