httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Webmaster33 <>
Subject [users@httpd] Apache Rewrite - Redirect Wildcard Subdomain
Date Thu, 15 Sep 2016 13:33:59 GMT
Using Apache 2.2.22.

I have the following SSL certificates:

    Common Name =
    Subject Alternative Names =, *

    Common Name =
    Subject Alternative Names =, *

I would like the following rewrite actions:
1) Redirect all unsecure requests to secure site, also requests from
old sites to new site   =>   =>

2) Keep request %{REQUEST_URI} between redirects. Also use wildcard
subdomains, and redirect them to secure new site, keeping wildcard
subdomain.   =>   =>

3) wilcard subdomains, which are NOT ALLOWED should redirected to
secure (aaa, bbb are not allowed)   =>   =>   =>   =>

No one is allowed, except those subdomains, which are listed in 4. point.

4) wilcard subdomains, which are ALLOWED should redirected to secure Allowed site:   =>   =>

My problem is, that

shows Server not found error.

All the 1), 2) kind of situations are redirecting fine. I have
problems getting result for 3), 4).

I have the following config files in /etc/apache2/sites-available/


Using VirtualHost config files like this (this is from

    <VirtualHost *:80>
        ServerAlias *

        RewriteEngine On

    RewriteCond %{HTTP_HOST} ^(.+\.)?$ [NC]
    RewriteRule ^/(.*)$1 [R=301,L]

How can I reach to get good redirection results for 3), 4) ?

Thanks in advance!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message