problem with redirecting to HTTPS automatically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

i'm using XAMPP on my linux notebook for local dev.
my first step was to create a folder to store my web application and to check that if user does not use HTTPS, he will be redirected to the same page but with HTTPS.

i know that it can be done using mod_rewrite but i was not able to make it works correctly.
In fact, since first page i want to force users to be under HTTPS.

so here is my virtualhost conf file:
<VirtualHost jobportal-admin.loc:80>
  DocumentRoot "/opt/lampp/htdocs/jobportal-admin/"
  ServerName www.jobportal-admin.loc
  ServerAlias jobportal-admin.loc
  ErrorLog "logs/jobportal-admin.loc-error_log"
  CustomLog "logs/jobportal-admin.loc.com-access_log" common
  Options Indexes FollowSymLinks Includes ExecCGI
  DirectoryIndex index.php

   <Directory "/opt/lampp/htdocs/jobportal-admin">
Options All
AllowOverride All
Require all granted
  </Directory>
</VirtualHost>

<VirtualHost jobportal-admin.loc:443>
    DocumentRoot "/opt/lampp/htdocs/jobportal-admin/"
    ServerName www.jobportal-admin.loc
    ServerAlias jobportal-admin.loc

    Options Indexes FollowSymLinks Includes ExecCGI
    
    DirectoryIndex index.php

    SSLEngine on
    SSLCertificateFile "/opt/lampp/etc/ssl.crt/server.crt"
    SSLCertificateKeyFile "/opt/lampp/etc/ssl.key/server.key"
    ErrorLog "logs/jobportal-admin.loc-error_log"
    CustomLog "logs/jobportal-admin.loc.com-access_log" common
    
    <Directory "/opt/lampp/htdocs/jobportal-admin">
        Options All
AllowOverride All
Require all granted
    </Directory>
</VirtualHost>

and in my .htaccess i have the following:

RewriteEngine On 

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www.jobportal-admin\.loc/ [NC]

RewriteRule ^(.*)$ https://www.jobportal-admin.loc/$1 [R,L]

but nothing is redirected to https :(

Any help would be appreciated.
thx a lot.
--
Alain
-----------------------------------------------------------
Kubuntu 17.04
MySQL 5.6.x
Apache 2.4.7 / OpenSSL 1.0.1c
Tomcat 7.17
PHP 5.6

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux