title: Why is apache redirecting to one of ServerAlias?
body: <p>I am using two top level domains <code>.pl</code> and <code>.net</code>. Both should always redirect to <code>https</code> version however when user go to <code>http://example.net/</code> apache redirects to <code>https://example.pl/</code>. Why it is preferable even when it is on third position in <code>ServerAlias</code>? Apache redirect to <code>.net</code> only if I remove <code>.pl</code> from <code>ServerAlias</code>.<br>
  My <code>/etc/apache2/sites-enabled/example.pl.conf</code> looks like this:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
     ServerName example
     DocumentRoot /var/www/example.pl
     ServerAlias example.net www.example.net example.pl www.example.pl
  &lt;/VirtualHost&gt;
  
  &lt;IfModule mod_ssl.c&gt;
      &lt;VirtualHost *:443&gt;
          ServerAdmin webmaster@localhost
  
          DocumentRoot /var/www/example.pl
  
          &lt;Directory "/var/www/example.pl"&gt;
                  Options FollowSymLinks
                  AllowOverride All
                  Require all granted
          &lt;/Directory&gt;
  
          ServerName example
  
          LogLevel trace8 rewrite:trace8
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          SSLEngine on
          SSLCertificateFile /etc/ssl/certs/2_example.pl.crt
          SSLCertificateKeyFile /etc/ssl/private/example.key
          SSLCertificateChainFile /etc/ssl/certs/1_root_bundle.crt
  
          &lt;FilesMatch "\.(cgi|shtml|phtml|php)$"&gt;
                  SSLOptions +StdEnvVars
          &lt;/FilesMatch&gt;
          &lt;Directory /usr/lib/cgi-bin&gt;
                  SSLOptions +StdEnvVars
          &lt;/Directory&gt;
  
          BrowserMatch "MSIE [2-6]" \
                  nokeepalive ssl-unclean-shutdown \
                  downgrade-1.0 force-response-1.0
          BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  
      &lt;/VirtualHost&gt;
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>And my <code>.htaccess</code>:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      &lt;IfModule mod_negotiation.c&gt;
          Options -MultiViews
      &lt;/IfModule&gt;
  
      RewriteEngine On
  
      RewriteCond %{HTTP_HOST} ^www\.(.*)
      RewriteRule ^.*$ https://%1/$1 [R=301,L]
  
      # Redirect Trailing Slashes If Not A Folder...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)/$ /$1 [L,R=301]
  
      # Handle Front Controller...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ index.php [L]
  &lt;/IfModule&gt;
  </code></pre>