Subdomain redirect without masking

Hi,

I have a subdomain on InfinityFree:

sub.mydomain.com

I want all traffic (HTTP or HTTPS) to redirect to an external URL:

https://example.com/path

My current redirect setup on Infinityfree:

URL: http://sub.mydomain.com (subdomain)

Type: Permanent (301)

Target: https://example.com/path (target URL)

Right now:

  • HTTPS works - the browser goes to the external URL
  • HTTP works - the content loads but the browser stays on sub.mydomain.com (masked)

I’m using Cloudflare with SSL enabled and the subdomain proxied.

How can I set up a normal 301 redirect so that both HTTP and HTTPS requests go to the external URL and no masked redirect is used?

So, in one short sentence: HTTP REDIRECT IS MASKED; HTTPS SHOWS TARGET CORRECTLY - WHY?

Thanks!

Please note that using placeholders significantly hinders our ability to troubleshoot as well as makes it less likely that you’ll get a useful reply.

7 Likes

If you setup a redirect with our Redirects tool, it will apply to all variants of your URL, including http://sub.example.com, https://sub.example.com, http://www.sub.example.com and https://www.sub.example.com.

If you setup a redirect rule in Cloudflare that is matched on the hostname, it will also apply to both HTTP and HTTPS.

Strictly speaking, a “redirect” only happens when you are sent to a new URL. There is no such thing as a “masked redirect”, URL masking is fundamentally different than redirecting, and technically that’s just an iframe that embeds the new site.

There are a couple of reasons that come to mind:

  • The specific redirect method you’re using actually uses URL masking.
  • The redirect doesn’t apply at all, and you’re just viewing the website you had uploaded to your subdomain with us.
  • There is some kind of weird caching issue that results in viewing the old page on HTTP but not on HTTPS.

In any case, it’s hard to help you when all we have is your description to go on.

Can you please give us the real URLs so we can see for ourselves what’s happening on it?

And could you please clarify which exact method you used to setup the redirect (our Redirects tool, Cloudflare, a setting in your website, custom .htaccess rules/HTML/PHP/Javascript)?

8 Likes

Thanks for your help. It seems the problem was caused by Firefox browser. I eventually set up the redirect in Cloudflare, but it works only in browsers other than Firefox.

Try using an incognito window on firefox, it might be that firefox is displaying the old page from cache

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.