• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2402
  • Last Modified:

http -->https RedirectMatch problems

Hi all, im trying to forward a http request to an https.  I've tried multiple configurations ive found online and only one example actually forwarded my request but wrecked my other virtual hosts in the process.

Ill explain my setup.

apache2.2 on 2003 server.
I have 10 virtualhosts in httpd.conf.
one of those virtual hosts has ssl.  That would be my shopping cart www.cart.com.  The other virtual hosts are all domains using RedirectMatch to pass to a specific pages within www.cart.com.  for example virtual host www.house.com points to https://www.cart.com/house/

here is my main vhost that is ssl.  i need this exact configuration but redirecting to https.
NameVirtualHost 1.2.3.4
<VirtualHost cart.com>
      ServerName www.cart.com      
      ServerAlias cart.com
      ServerAdmin webmaster@cart.com
      DocumentRoot "D:/apache/htdocs/cart"
      ErrorLog logs/cart.com-error_log
      CustomLog logs/cart.com-access_log common
      SSLEngine On
      SSLCertificateFile conf/ssl/cart.crt
      SSLCertificateKeyFile conf/ssl/cart.key
                SSLCACertificateFile conf/ssl/intermediate.crt
    <Directory "D:/apache/htdocs/cart">
        AllowOverride All
    </Directory>
</VirtualHost>

the below vhosts worked for making http and https work but what ended up happening when i went to www.house.com it did a RedirectMatch to http://www.cart.com/house when it should have been https://www.cart.com/house

NameVirtualHost 1.2.3.4
<VirtualHost cart.com:80>
      ServerName www.cart.com      
      ServerAlias cart.com
      ServerAdmin webmaster@cart.com
      DocumentRoot "D:/apache/htdocs/cart"
      ErrorLog logs/cart.com-error_log
      CustomLog logs/cart.com-access_log common
    <Directory "D:/apache/htdocs/cart">
        AllowOverride All
    </Directory>
</VirtualHost>


NameVirtualHost 1.2.3.4
<VirtualHost cart.com:443>
      ServerName www.cart.com      
      ServerAlias cart.com
      ServerAdmin webmaster@cart.com
      DocumentRoot "D:/apache/htdocs/cart"
      ErrorLog logs/cart.com-error_log
      CustomLog logs/cart.com-access_log common
      SSLEngine On
      SSLCertificateFile conf/ssl/cart.crt
      SSLCertificateKeyFile conf/ssl/cart.key
                SSLCACertificateFile conf/ssl/intermediate.crt
    <Directory "D:/apache/htdocs/cart">
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost 1.2.3.4.5>
      ServerName house.com      
      ServerAlias house.com
      ServerAdmin webmaster@house.com
      DocumentRoot "D:/apache/htdocs/cart/house/"
      ErrorLog logs/cart.com-error_log
      CustomLog logs/cart.com-access_log common
        RedirectMatch ^/$ https://www.cart.com/house?1234
    <Directory "D:/apache/htdocs/cart/house">
        AllowOverride All
    </Directory>
</VirtualHost>
0
domoaarongato
Asked:
domoaarongato
1 Solution
 
giltjrCommented:
I would suggest that instead of doing the redirect in the virutal host defintion that you do it in .htaccess file.

This way the redirect is done after virtual host processing as been looked at.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now