httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raf Roger <raf.n...@gmail.com>
Subject [users@httpd] problem with redirecting to HTTPS automatically
Date Fri, 21 Apr 2017 04:14:09 GMT
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

Mime
View raw message