0

I have tried following;

If a user try to access my website http://test.com it will redirect to https://test.com but if a user try accessing internal page like http://test.com/test1 it doesn't redirect to https. I have tried following code in my .htaccess file.

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Full .htaccess file

# 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]

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

</IfModule>
Aamir Shahzad
  • 6,683
  • 8
  • 47
  • 70

1 Answers1

0

Instead of testing for !on test for off -

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • What does the rest of your .htaccess file look like? – Jay Blanchard Apr 10 '15 at 10:42
  • ` RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] ` – Aamir Shahzad Apr 10 '15 at 10:45
  • Please don't dump code in comments. Update your original post with the additional information. – Jay Blanchard Apr 10 '15 at 10:49