Redirect https canonicals

Hi,

I have configured name-base virtual hosting with two domains.
  1. DOMAIN.COM
  2. DEV.DOMAIN.COM
I have configured the first host in ‘httpd-vhosts.conf’ exactly as follows (read the comments):

<VirtualHost *:80>
# ServerName is absent to default to the "main" server configuration
# in ‘httpd.conf’ for requests that do not match any particular virtual
# host listed below.
</VirtualHost>

This way ANYCRAP.DOMAIN.COM goes to a common “why are you here page.” The domains in 1 -4 below are directed (and function) appropriately for:
  1. HTTP://DOMAIN.COM
  2. HTTP://WWW.DOMAIN.COM
  3. HTTP://DEV.DOMAIN.COM
  4. HTTP://WWW.DEV.DOMAIN.COM

The problem is with HTTPS://ANYCRAP.DOMAIN.COM. I have configured ‘httpd-ssl.conf’ for DOMAIN.COM, which works fine.

What I would like to do is have:
  1. HTTPS://DOMAIN.COM
  2. HTTPS://WWW.DOMAIN.COM

resolve to the secure pages and
HTTPS://ANYANDALLCRAP.DOMAIN.COM
redirect to the same aforementioned “why are you here page.”

I tried using the Apache Module mod_rewrite module, but without success. Here is what I tried:
# if port 443 (https)
RewriteCond %{SERVER_PORT} ^443$

# if it doesn’t start with domain.com doesn’t start with www
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]

# and if its not the main domain
RewriteCond %{HTTP_HOST} !^domain\.com [NC]

# use port 80 (http)
RewriteRule %{SERVER_PORT} ^80$

# resolve requests to this file
RewriteRule (.*) /usr/local/www/vhosts/default/htdocs/index.html
Ideas?

FreeBSD 8.0-RELEASE
Apache-2.2.15_9
  • Files used in Apache configuration:
  • /usr/local/etc/apache22/httpd.conf
  • /usr/local/etc/apache22/extra/httpd-default.conf
  • /usr/local/etc/apache22/extra/httpd-vhosts.conf
  • /usr/local/etc/apache22/extra/httpd-ssl.conf
Comments
Advertisements
Zimbio Entertainment
Copyright © 2012 - Zimbio, Inc. Some rights reserved. Coming soon: Livingly
Share
. . .
Follow
. . .