0

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>
1
<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.

0

Why are you duplicating your virtual hosts definitions? You can just use a line like:

ServerAlias www.domain.com domain.com

Here is the reference. So, one of the VH should be enough instead of two (of port 80). You can keep the working one :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.