Redirect Permanent and https

apache-2.2https

I just set up https on my server, and I have an issue with redirect permanent.

If I have a link for example http://domain.com/index.html it redirect me on

https://www.domain.comindex.html

The / is missing and I can't figure out how to fix it.

It's work with http://www.domain.com/index.html

Here is my httpd.conf

<VirtualHost *:80>
  ServerName domain.com
Redirect permanent / https://www.domain.com/
</VirtualHost>
<VirtualHost *:80>
  ServerName www.domain.com
  Redirect permanent / https://www.domain.com/
</VirtualHost>

<VirtualHost *:443>
  DocumentRoot /var/www/domain/
  ServerName www.domain.com
  SSLEngine on
  SSLCertificateFile ssl.crt
  SSLCertificateKeyFile ssl.key
</VirtualHost>

Best Answer

<VirtualHost *:80>
  ServerName www.domain.com
  ServerAlias domain.com
  Redirect permanent / https://www.domain.com/
</VirtualHost>

Get rid of the second one.

Your original problem was a typo in the target; the source and target of a redirect must have matching slashes.

Browser cache persistence explains the rest.

Also note that in apache 2.2, NameVirtualHost *:80 is not optional, if you have more than one vhost.

In apache 2.4, it guesses what you mean and does the right thing.

Related Topic