Change Protocol For Certain Files

I followed the steps in one of your articles to force all traffic to go to https. I’m wondering if it’s possible to exclude some files from this change so that only those can be viewed at http?

I think you can perhaps make a redirect?

You could add a rule to your .htaccess for that specific file

What would I type there for that? I’ve never done this.

That might cause an endless redirect loop.

1 Like

Redirecting a single URL

Using Redirect in an .htaccess file enables you to redirect users from an old page to a new page without having to keep the old page. For example, if you use index.html as your index file and then later rename index.html to home.html, you could set up a redirect to send users from index.html to home.html. For example:

    **Redirect to a local site file**

    Redirect /path/to/old/file/old.html /path/to/new/file/new.html

    **Redirect to an external site file**

    Redirect /path/to/old/file/old.html https://www.example.com/new/file/new.html

This may work, never tried it, LOL

I don’t have a new and an old version though.

You could try:

RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteCond %{REQUEST_FILENAME} =<URL of the file without domain>
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

and replace <URL of the file without domain> with say /example.txt.

I haven’t tested this though.

2 Likes

Just ignore that. Redirect https to http, I guess

Does it take time to take effect? It won’t work.

This is the URL by the way:

http://files.rydercragie.com/Other/WebsiteIcons.html

This is what my htaccess file looks like:

Why do you need it on HTTP? That’s not the best idea, and some browsers will detect the mixed content, showing a warning to users.

Trying to update the iframe on my main website. The white flash is annoying me. But it won’t load when I embed it on my site. I think using it with http might work better. That said, it might not.

Nah, it after all redirects to https

I don’t see a white flash on the URL you provided.

1 Like

I have highlighted some errors in your code:

This is looking for </Other/WebsiteIcons.html> not /Other/WebsiteIcons.html. Try replacing the code block I posted earlier with this:

RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteCond %{REQUEST_FILENAME} =/Other/WebsiteIcons.html
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Done.

1 Like

I mean RyderCragie.com. Hence “main website”.

For starters, if you try to embed a HTTP resource in an HTTPS page, the HTTP resource will just not load. Modern browsers refuse to load in unprotected assets in a protected page for security.

An iframe means the browser has to request a new page from the server, the server has to fetch it, the browser has to download it and then render the content. This takes a bit of time. If you don’t want this, then not using iframes is probably your best bet.

2 Likes

Thanks. I’ve asked somewhere else to see if they can help me fix the code.