You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Raf Roger <ra...@gmail.com> on 2017/04/21 04:14:09 UTC

[users@httpd] problem with redirecting to HTTPS automatically

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

Re: [users@httpd] problem with redirecting to HTTPS automatically

Posted by Eric Covener <co...@gmail.com>.
On Fri, Apr 21, 2017 at 12:14 AM, Raf Roger <ra...@gmail.com> wrote:
> <VirtualHost jobportal-admin.loc:80>


Why not *:80?
Why not just put a Redirect directive in the port 80 vhost if all it
does is redirect to HTTPS?


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org