1
votes

I am trying to route all the ssl request to non-ssl and below scenarios works fine except one [ 4th from below list] and i am not sure what is wrong , can you please help me out in this

1 - http://www.domain.com -- redirect to www.domain.com - --> works fine

2 - http://domain.com -- redirect to www.domain.com --> works as expected

3 - https://domain.com -- redirect to www.domain.com --> works as expected

4 - https://www.domain.com --redirects to https://www.domail.com -- expected to be www.domain.com

        <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index.html%{ENV:W3TC_ENC}" [L]
    </IfModule>

    <IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    <IfModule>

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
    <IfModule>

Here , I want to redirect all the request coming on https://www.domain.com to www.domain.com , and below is the .htaccess config details we have ,

Thanks , I really appreciate you support ..

- Manoj

2
Just to make sure I understand the desired outcome here, you want to send all requests to port 80, but ensure that www. is included in the url? - Chris Rasco

2 Answers

0
votes

Get rid of these lines:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

(there are two sets of them)

You don't want them there because it is after you are routing everything to index.php.

Instead, add this right before the RewriteRule ^index\.php$ - [L] line:

RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
0
votes

Rackspace cloud servers run behind a load balancer which decrypts the SSL, so the RewriteCond %{HTTPS} condition will never be met.