Redirect https canonicals - help

Discussion in 'Apache' started by jwnetsource, Jun 24, 2010.

  1. #1
    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 please.


    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
     
    jwnetsource, Jun 24, 2010 IP
  2. jwnetsource

    jwnetsource Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Actually, there are 3 domains, the default domain, a.k.a ANYCRAP.DOMAIN.COM, and the 1 & 2 listed in the original post.
     
    jwnetsource, Jun 24, 2010 IP