Reputation: 1
I am trying to redirect http://www.example.com/page/
urls to https://www.example.com/page/
and have tried some code suggestions from here but was getting infinite redirect loops. I also tried using cpanel but that gave 404 errors. I have also moved the redirects above the mod_rewrite section when doing it from cpanel as they normally don't work otherwise.
Am using current wordpress + cloudflare with HTTPS plugin to keep whole site in https://www
which is working well.
This is what I can find in wp-config.php and .htaccess currently:
wp-config.php:
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';
.htaccess:
# 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
Preferably, any attempts to access a http://www.example.com/page/
url would result in a 301 redirect to the https://www.example.com/page/
version of the same url.
Does anyone have any suggestions?
Thank you in advance!
Upvotes: 0
Views: 755
Reputation: 147
Have you considered using a plugin instead?
I suspect this plugin may do exactly what you want:
WordPress HTTPS (SSL) https://wordpress.org/plugins/wordpress-https/
If that doesn't solve the problem you could try something like this using mod_alias
Redirect permanent /page https://www.example/com/page
in your the site file in /etc/apache2/sites-enabled
Upvotes: 0