Home .htaccess redirect HTTP to HTTPS with mod_rewrite not working
Reply: 0

.htaccess redirect HTTP to HTTPS with mod_rewrite not working

user1912
1#
user1912 Published in May 21, 2018, 5:05 pm

I'm trying to redirect all the connections to my website from http to https using htaccess and mod_rewrite, I've tried all the possible things and still not working, I get an error like: The page is not redirecting properly

Here goes the htaccess code:

ErrorDocument 404 http://www.example.com/error.php

<IfModule mod_rewrite.c>

Options -Indexes

Options +FollowSymlinks

RewriteEngine on

RewriteBase /

RewriteCond %{HTTPS} on 

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^([^/]*)\.html$ /index.php?lang=$1 [L]

RewriteRule ^sites/examplesite/([^/]*)\.html$ /index.php?lang=$1 [L]

RewriteRule ^([^/]*)/examplesite/([^/]*)\.html$ /index.php?lang=$1&page=$2 [L]

RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?lang=$1&page=$2 [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&idCat=$2&page=$3 [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&cat=$2&filter=$3&pa=$4&page=$5 [L]

RewriteRule ^sites/examplesite/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&page=$2 [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&show=$2&page=$3 [L]

RewriteRule ^sites/examplesite/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&itemID=$2&idCat=$3&page=$4 [L]

RewriteRule ^sites/examplesite/([^/]*)//([^/]*)/([^/]*)\.html$ /index.php?lang=$1&idCat=$2&page=$3 [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?lang=$1&idCat=$2&client_id=$3&page=$4 [L]

</IfModule>

<FilesMatch "\.(ttf|otf|eot|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>



   php_flag display_errors On
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.248138 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO