I set up a new virtual host for a new site on my server, but it's acting strangely despite having the exact same settings as my original site.
I want all requests to be redirected to HTTPS, simply put. On my main site (the working one) I have this specified in the VirtualHost config, and in .htaccess I have an additional rule specified to allow short URLs. Specifically, the problem on the non-working site is that if I try to go to example.com/url, the redirect goes to https://example.comurl and removes the necessary / from the URL.
I copied the exact config over to the new VirtualHost and .htaccess file from the working site so I'm not sure why it doesn't work on the new one. My DNS records for both sites all use A records to point to it, no redirects or anything happen at the DNS level. I have tried putting a / at the end of the Redirect lines in the code below, but the problem was not resolved. The server is Ubuntu 14.04, and Apache is version 2.4.7. Both sites are separate domain names with separate .conf files used, but they are hosted on the same server with the same IP address. How can I fix this problem?
The relevant code in the VirtualHost:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com
</VirtualHost>
And in .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
In case it helps/matters, this is the SSL config in my VirtualHost file, though it is placed at the very beginning of the file outside of all other directives:
SSLCipherSuite AES128+EECDH:AES128+EDH
SSLProtocol All -SSLv2 -SSLv3
SSLHonorCipherOrder On
Header always set Strict-Transport-Security "max-age=63072000; includeSubdo$
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
And this is the config specifically for the VirtualHost for the site:
<VirtualHost *:443>
ServerName example.com
ServerAdmin user@example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/errorexample.log
Options -Indexes
SSLEngine on
SSLCertificateFile /etc/ssl/example/examplecert.crt
SSLCertificateKeyFile /etc/ssl/example/examplekey.key
SSLCertificateChainFile /etc/ssl/chain/class1.pem
</VirtualHost>