1

I have a few static files on a i. subdomain but I don't have an SSL certificate and for its use it doesn't need one, however when I try to access it - it redirects for https which throws up an error and doesn't work.

I am currently using this in my .htaccess

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

What is needed to make it ignore the i. subdomain?

0

1 Answer 1

1

Add another condition to exclude the subdomain:

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

Presumably the www canonicalisation is already handled elsewhere?

This should probably be a 301 (permanent) redirect, rather than a 302 (temporary).

There is no need to capture the RewriteRule pattern (ie. (.*)) unless you are using it in the substitution.

2
  • 1
    @OfficialAntarctica serving static files from a HTTP sub domain to your HTTPS site means your main site will notify people that your site is not secure... Do yourself a favour and use a proper CDN with SSL, a sub domain serving files is no where near as fast as a dedicated CDN with multiple locations throughout the world. Sep 28, 2015 at 15:24
  • @SimonHayter I came to that conclusion an hour ago, the subdomain will be https
    – Zed
    Sep 28, 2015 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.