1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Vhost redirect captures request for other (deactivated) vhost

Discussion in 'Apache' started by Ficus elastica, Jul 8, 2021.

  1. #1
    Hi out there! I am an Apache amateur, have learned a lot about Apache configuration but still I am not familiar with the "Redirect" function.
    We are hosting 2 domains "perrypedia.de" and "perrypedia.proc.org", the latter is the old domain name that is to be redirected to the new one. Within perrypedia.de, there are two wikis running, test.perrypedia.de and www. perrypedia. de. Also, all requests without SSL shall be redirected to https. To achieve this, I created four config files with a total of five Vhosts. They work perfectly well and stable (... with one exception I'll tell later).

    Ubuntu 18.04, Apache 2.4.29

    Testwiki, http:
    <VirtualHost *:80>
            ServerName test.perrypedia.de
            Redirect 301 "/" "https://test.perrypedia.de/"
    </VirtualHost>
    Code (markup):
    Testwiki, https:
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
            ServerName test.perrypedia.de
            DocumentRoot /var/www/test
            RewriteEngine on
            RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/index.php [NE]
            RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki/index.php [NE]
    (... a lot more directives: logging, SSL certificate, bandwidth, directory access ...)
    </VirtualHost>
    </IfModule>
    Code (markup):
    Productive, http:
    <VirtualHost *:80>
            ServerName www.perrypedia.de
            ServerAlias perrypedia.de
            ServerAlias www.perrypedia.proc.org
            ServerAlias perrypedia.proc.org
            Redirect 301 "/" "https://www.perrypedia.de/"
    </VirtualHost>
    Code (markup):
    Productive, https:
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
            ServerName www.perrypedia.de
            ServerAlias perrypedia.de
            DocumentRoot /var/www/prod
            RewriteEngine on
            # add www
            RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
            RewriteCond "%{HTTP_HOST}" "!^$"
            RewriteRule "^/?(.*)"      "https://www.%{HTTP_HOST}/$1" [L,R,NE]
            # Short url
            RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/index.php [NE]
            # Redirect / to main page
            RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki/index.php [NE]
            # Cache
            RewriteCond %{HTTP_COOKIE} !UserID=
            RewriteCond %{QUERY_STRING} !.
            RewriteCond %{THE_REQUEST} ^GET\x20/wiki/([^\x20/]+)\x20HTTP
            RewriteCond %{DOCUMENT_ROOT}/mediawiki/cache/%1.html -s
            RewriteRule ^wiki/(.+)$ /mediawiki/cache/%1.html [B,L,NS]
    (... a lot more directives: logging, SSL certificate, bandwidth, AWStats, directory access ...)
    </VirtualHost>
    <VirtualHost *:443>
            ServerName www.perrypedia.proc.org
            ServerAlias perrypedia.proc.org
    (... SSL ...)
            Redirect 301 "/" "https://www.perrypedia.de"
    </VirtualHost>
    </IfModule>
    Code (markup):
    The redirects and rewrite-rules are mostly not my invention but put together from several web resources. Nearly everything is fine ... now here's the problem I cannot deal with. When I shut down the productive site (a2dissite prod-http & https), immediately the Testwiki grabs ALL http-requests even that for the productive site. And vice versa (stopping Testwiki leads ALL http-test-URLs to the prod wiki). This seems to happen because of the unspecific Redirect 301 "/" ... I thought the Vhost grabs only URL matching its server name or aliases, but now I am in doubt. I want to learn and understand what I am doing wrong. Anyone having a valuable hint?
     
    Ficus elastica, Jul 8, 2021 IP
  2. Ficus elastica

    Ficus elastica Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    3
    #2
    I requested to delete his post and to delete my profile. I used the "report this post" feature because there is NO contact address, NO administrator, NO ONE responsible for this forum. There is NO WAY to edit or remove a posting, NO WAY to delete my profile, NO WAY to resign or leave this forum. This is stone age.

    DIGITAL POINT IS DIGITAL BULLSHIT !!!
     
    Ficus elastica, Aug 31, 2021 IP