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've been trying to redirect web traffic from HTTP to HTTPS by adding the line to the httpd.conf file:

Redirect permanent / https://100.100.100.100

but to no avail. The browser response is Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

I understand that it works for domain names but my server doesn't use one. Is there any way around this/what am I doing wrong.

share|improve this question
    
Have you configured Apache to listen on port 443 and referenced an SSL certificate? Please post the host configuration from httpd.conf –  Mathias R. Jessen Jan 23 '12 at 22:42
    
One of the problems with using a permanent redirect is that Firefox will cache it. (Maybe not the redirect delivered over SSL but definitely the one delivered over non-SSL.) Even once you fix this problem, Firefox will continue to give you that error message until you clear that part of its cache. Use curl -I http://100.100.100.100 to check what response code you get back without having to worry about caching. –  Ladadadada Jan 23 '12 at 22:53
    
@JudasIscariot1651 Yes SSL certificate is installed and when I enter 'https://' 100.100.100.100' in browser it works no problem. I want 'http://' 100.100.100.100 to redirect to https://... –  wonderswan Jan 23 '12 at 22:55

2 Answers 2

up vote 4 down vote accepted

I suspect that your Redirect line is in a part of the config file that affects both the SSL and non-SSL parts. Therefore, even when you request the SSL version you still get a redirect to the SSL version.

If you have a part of the config file that is for non-SSL only, move the Redirect there. If not, convert it to a RewriteRule and use a RewriteCond in front of it like this:

RewriteCond %{HTTPS} off
RewriteRule / https://100.100.100.100/ [R=301]
share|improve this answer
    
Thank you I'm so grateful –  wonderswan Jan 23 '12 at 23:30

Use mod_rewrite:

   RewriteEngine On
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L]
share|improve this answer
    
Thank you for your help –  wonderswan Jan 23 '12 at 23:30

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.