Rob
Rob

Reputation: 3853

redirect entire site from http to https except for one page

I want to redirect my entire site from http to https except for one page ( a file to be download actually ) but am having troubles

I am currently using

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

from this post ... htaccess redirect to https://www

but have not figured out how to exclude the one file I need.

it is more or less

http://www.something.com/phone/version/currentversion.txt

I tried redirecting the https version of it back to the http version, but I got an error that said something along the lines that I was in an endless loop of resolution and it would not work

any help would be appreciated

Upvotes: 1

Views: 251

Answers (1)

Cillian Collins
Cillian Collins

Reputation: 728

A simple mod_rewrite exception should work:

RewriteEngine On
RewriteCond %{REQUEST_URI} !/phone/version/currentversion.txt
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Upvotes: 2

Related Questions