Your server creates the door variable 443 or https on or 1, obviously you must have https already active on your server.
try this script if you can identify what you use for https. test.php
<?php
print_r($_SERVER);
call test.php from the browser https://yourdomain.com/test.php
The https rules will take precedence over everything, you have to put them just below RewriteBase /
If test.php gives you $_SERVER[‘HTTPS’] = ‘On’;
RewriteCond %{HTTPS} !On [OR]
RewriteCond %{HTTP_HOST} !^yourdomain\.com [NC]
RewriteRule [^/]? https://yourdomain.com%{REQUEST_URI} [R=301,L]
Valid for forwarding on a single domain does not use the variable HTTP_HOST simply use your domain, also to control the domain use your domain otherwise even the domains of fourth level are valid example http://www.forum.yourdomain.com or http://forum.yourdomain.com π
My Site has been up for a while now with only https so that part is done. However I want to catch those people that dont know the difference between www,http,https,etc and kick them right to my site. That is the code i need!! Should I replace all of what I have in my htaccess with this?
RewriteCond %{HTTPS} !On [or]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule [^/]? https://yourdomain.com%{REQUEST_URI} [R=301,L]
if you have only one channel use the negation also for htaccess is the character! !^yourdomain\.com means if different from yourdomain.com
I’m sorry, can you elaborate on what you just said?
Redirect from http://www.forum.yourdomain.com http://forum.yourdomain.com https://www.forum.yourdomain.com
https://forum.yourdomain.com
https://www.yourdomain.com http://yourdomain.com
To https://yourdomain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^yourdomain\.com [NC,OR]
RewriteCond %{HTTPS} !On
RewriteRule [^/]? https://yourdomain.com%{REQUEST_URI} [R=301,L]
Sorry π
AHH! ok. Thank you. Now when I try that and comment out the code I had I get redirect loops and even https://example.com doesn’t come up.
Exist $_SERVER[‘HTTPS’] =’On’ ?
I edited the code six minutes ago
So this is all i have currently being used in htaccess but i still get a too many redirects
# 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]
# FOrce ALL to HTTPS
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^stonesorganics\.com [NC,OR]
RewriteCond %{HTTPS} !On
RewriteRule [^/]? https://stonesorganics.com%{REQUEST_URI} [R=301,L]
can you create a test.php page?
<?php
print_r($_SERVER);
I need the url of this page
<IfModule mod_rewrite.c>
# FOrce ALL to HTTPS
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^stonesorganics\.com [NC,OR]
RewriteCond %{HTTPS} !on
RewriteRule [^/]? https://stonesorganics.com%{REQUEST_URI} [R=301,L]
</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>
Prove this with ‘on’ lowercase.
That gave me a 500 error on all pages. Did you post then modify again by chance?
yes but I have to understand why .. I copied your code .. It may be because it sees ifmodule RewriteEngine and RewriteBase twice.
try like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
# FOrce ALL to HTTPS
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^stonesorganics\.com [NC,OR]
RewriteCond %{HTTPS} !on
RewriteRule [^/]? https://stonesorganics.com%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ β [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
make sure you nest properly ifmodule, if you have two open only two closed will exist.
That also gets me a 500 error
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^stonesorganics\.com [NC,OR]
RewriteCond %{HTTPS} !^on
RewriteRule [^/]? https://stonesorganics.com%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ β [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
sorry this code works for me i have no more ideas.