Re: Redirecting virtual host to https in Apache 2.4

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

 



That implies that you are not hitting the VirtualHost that you expect.
This is the exact configuration I use on one of my servers:
    RewriteEngine On
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Can you look at your access logs and see which VirtualHost you are accessing?

You can use this log type to help make sure: 
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

- Y



On Tue, Feb 18, 2014 at 4:27 PM, David Mehler <dave.mehler@xxxxxxxxx> wrote:
Hello,

I'm running Apache 2.4 on an FC20 box. It's running several name based
virtual hosts.

I've set up one name based virtual host on port 443 I'll call it
webmail.example.com. When a user goes to https://webmail.example.com
the connection encrypts, the page is displayed. Here's the original
version of that virtual host:

<VirtualHost webmail.example.com:443>
     ServerAdmin webmaster@xxxxxxxxxxx
     ServerName webmail.example.com
 ServerAlias webmail.example.com
     DocumentRoot /srv/http/webmail
     ErrorLog "/var/log/httpd/webmail.example.com_error_log"
     CustomLog "/var/log/httpd/webmail.example.com_access_log" common
SSLEngine on
SSLCipherSuite HIGH
SSLCertificateFile "/etc/ssl/certs/server.crt"
SSLCertificateKeyFile "/etc/ssl/private/server.key"
<Directory /srv/http/webmail>
Options FollowSymLinks
AllowOverRide Limit
Require all granted
DirectoryIndex index.php
</Directory>
</VirtualHost>

My problem is I'm wanting a rewrite rule that will redirect any users
who just go to:

http://webmail.example.com

to:

https://webmail.example.com

so they'll hit the ssl enabled virtual host. I'm getting page not
founds. Here's my configuration:

<VirtualHost webmail.example.com:80>
     ServerAdmin webmaster@xxxxxxxxxxx
     ServerName webmail.example.com
    ServerAlias webmail.example.com
     DocumentRoot /srv/http/webmail
     ErrorLog "/var/log/httpd/webmail.example.com_error_log"
     CustomLog "/var/log/httpd/webmail.example.com_access_log" common
# I've tried all this:
#    Redirect / https://webmail.example.com/
#    Redirect http://webmail.example.com/ https://webmail.example.com/
  #RewriteEngine  on
  #RewriteCond    %{HTTPS} !=on
  #RewriteRule (.*) https://%{HTTP_HOST}
  #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

Pointers welcome.
 
http://xkcd.com/138/
 
Thanks.
Dave.

[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