Redirection unable to force SSL

I’ve Google and found so many variations on how to do ReWrite rule, but I could find one that work…

I want URLs of site to always redirect to the www version and force SSL.

I want http://www.example.com to go to https://www.example.com
I want https://example.com to go to https://www.example.com

The first case is not working. Getting error “This page isn’t redirecting properly. Server is redirecting the request fo thsi address in a way that will never complete”

My code is …


RewriteCond %{HTTP_HOST} ^example\\.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteRule ^.*shop/images/(\\d+)/?\\??(.*)$ /wp-content/plugins/shopp/core/image.php?siid=$1&$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Redirect 301 /ed-other.html https://www.example.com/other.html 


Or see …
http://blissfulwriter.com/temp012811/redirect-problem.jpg

art,

Have you bothered to look at the sticky posts here? How about the tutorial linked in my signature?

Okay, let me comment on your code:

RewriteCond %{HTTP_HOST} ^example\\.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
# Fine!  Force www on the domain name

RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
# Fine!  Force the use of the secure server

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# This is the problem as %{HTTP_HOST} could still be
#    example.com which would cause a loop

# BEGIN WordPress
[COLOR="Red"]<IfModule mod_rewrite.c>
# ARGH!  This severely abuses your server!  Do NOT use this wrapper![/COLOR]
RewriteEngine On
[COLOR="Red"]RewriteBase /
# Unnecessary[/COLOR]
RewriteRule ^index\\.php$ - [L]
[COLOR="Red"]RewriteRule ^.*shop/images/(\\d+)/?\\??(.*)$ /wp-content/plugins/shopp/core/image.php?siid=$1&$2 [QSA,L]
# No!  You're trying to examine the {REQUEST_URI} in
#   this RewriteRule and that will NEVER happen![/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
[COLOR="Red"]</IfModule>
# see above[/COLOR]
# END WordPress

Redirect 301 /ed-other.html https://www.example.com/other.html 
# This will happen first because mod_alias is part of Apache's core.
# What happens to other.html is dependent upon whether it exists (-f) or not.

Regards,

DK