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>
This is a late answer but this works for me:
Change the RewriteCond to this
Should be like this:
Without being an htaccess expert, I’d say you’re missing a
RewriteCond
– A condition.Check if it’s on port 80. Try this:
UPDATE:
After seeing your updated question, with the full .htaccess – I’d do this:
Having your condition and rule underneath WordPress’ standards.
Source https://www.godaddy.com/help/redirect-http-to-https-automatically-8828
or for just a single page
or you can add this php to a particular file
or combine the wordpress rewrite rules with the SSL ones..
Web sites behind load balancers or reverse proxies that support
HTTP_X_FORWARDED_PROTO
can be fixed by adding the following code to thewp-config.php
file, above the require_once call:or by using a plugin
Add into WordPress plugins folder on your website, then activate it in the Plugins admin
Source
It is working like
http://www.exmaple.com/blog/
tohttps://www.exmaple.com/blog/
http://www.exmaple.com/
tohttps://www.exmaple.com/