Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
share|improve this question
add comment

2 Answers

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

share|improve this answer
add comment

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 :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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