Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

Example http://domain.com/index.html it redirect me to http://www.domain.comindex.html

The / (tail ending slash) 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
2  
Odd -- should be working just fine. Try RedirectMatch instead: RedirectMatch 301 ^(.*)$ https://www.domain.com$1 -- see if it makes the difference. Also -- modern browsers do cache permanent redirects, so if it failed first time, then browser may still be using old redirect. I suggest clear browser cache and restart it (and/or try another browser). –  LazyOne Apr 24 '12 at 13:10

2 Answers 2

Change to this and try it, notice only two VirtualHost

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias *.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 answer

I had that same issue, and don't know why it is failing either. I was able to work around it using this instead:

<VirtualHost *:80>
    ServerName domain.com
    ServerAlias *.domain.com
#   Redirect 301 / https://www.domain.com
    RedirectMatch permanent /(.*) https://www.domain.com/$1
</VirtualHost>
share|improve this answer
    
Please use answer to answer the question. –  Zistoloen Mar 4 '13 at 20:33
    
@Zistoloen - It looks like a fine answer to me. Why do you feel it's not an answer? –  Kevin Fegan Apr 19 '13 at 1:29
    
@Kevin Fegan: I spoke to a user that has commented this answer but the user deleted his comment. –  Zistoloen Apr 19 '13 at 9:03

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.