Rebecca Winslow
Rebecca Winslow

Reputation: 13

HTTP Addresses on my domain Redirect To The Homepage Of the HTTPS Version

I recently switched over to HTTPS from HTTP and I am having trouble with my redirect. Now the any URL with the http version of my site just automatically redirects to the https Homepage no matter where it is supposed to go in the site. I know the https version of the URL works but if there is any http of any url throughout the site it just goes to the http homepage. I am almost positive it is something to do with to the .htaccess code.

My .htaccess file is this:

RewriteCond %{HTTP_HOST} ^flashionstatement.com$ [OR] 
RewriteCond %{HTTP_HOST} ^www.flashionstatement.com$ 
RewriteCond %{SERVER_PORT} ^80$ 
RewriteCond %{REMOTE_HOST} !^108\.161\.1[789][0-9]\.122
RewriteCond %{REMOTE_HOST} !^94\.46\.14[67]\.122
RewriteRule ^(.*)$ https://www.flashionstatement.com [R=301,L]
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
    Header append Vary User-Agent env=!dont-vary
</IfModule>
    AddOutputFilterByType DEFLATE text/css text/x-component   application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
    # DEFLATE by extension
    AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
    Header append Vary User-Agent env=!dont-vary
</IfModule>
    AddOutputFilterByType DEFLATE text/css text/x-component    application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
    # DEFLATE by extension
    AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
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%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%  {REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
 </IfModule>
 # END W3TC Page Cache core

Iam not exactly sure what to change as lots of people have worked on this .htaccess file from my company in the past. Below is the Curl output showing http://www.flashionstatement.com/custom-led-shirts/ somehow is redirecting to the homepage and I suspect this is happening on every URL that is http instead of leading them to the https version of the page.

curl -I http://www.flashionstatement.com/custom-led-shirts/
HTTP/1.1 301 Moved Permanently
Date: Thu, 12 May 2016 16:03:00 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Set-Cookie: __cfduid=db442124903d47a3e50ca46dd12d2c3321463068980;    expires=Fri, 12-May-17 16:03:00 GMT; path=/; domain=.flashionstatement.com;   HttpOnly
Location: https://www.flashionstatement.com
Vary: Accept-Encoding
Server: cloudflare-nginx
CF-RAY: 2a1f19260c914020-SOF

Any help would be so appreciated if you think you know what is going on. Thanks in advance!

Upvotes: 1

Views: 53

Answers (1)

Panama Jack
Panama Jack

Reputation: 24458

That is because you are not using the captured URI in your rewriterule substitution so that it also forwards the URI. (the part after the domain).

change this

RewriteRule ^(.*)$ https://www.flashionstatement.com [R=301,L]

To this

RewriteRule ^(.*)$ https://www.flashionstatement.com/$1 [R=301,L]

Clear your cache and try this update. Let me know how it works.

Upvotes: 1

Related Questions