My WordPress website is located at example.com/wordpress and I need everything inside to be accessible only using SSL.

I’ve created a .htaccess rule that redirects http -> https:

RewriteEngine On
RewriteRule ^/?(.*) https://%{SERVER_NAME}/wordpress/directory/$1 [R,L]

After implementing this rule the website is inaccessible as it is stuck in a redirect loop.

What am I doing wrong?

My WordPress .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/directory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/directory/index.php [L]
</IfModule>

5 Answers
5

This is a late answer but this works for me:

Change the RewriteCond to this

RewriteCond %{HTTP:X-Forwarded-Proto} !https

Should be like this:

RewriteEngine On 
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]

Leave a Reply

Your email address will not be published. Required fields are marked *