How to redirect '' to '' in just 1 step


I removed a subdomain of my website (, and redirected all the traffic to ‘’, through the Apache htaccess configuration:

RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [R=301,L]

However the non-HTTPS traffic (e.g. ‘’) needs two 301 redirects:

  1. --301–> (through the Cloudflare configuration of ‘Always Use HTTPS’)
  2. --301–> (through my Apache httaccess)

These two steps slow down the speed, and make Googlebot to crawl two times my URLs.

Is there any way in Cloudflare to save one step from ‘’ to ‘’?

Thank you.

Create a redirect rule here…

Like this…


Thank you very much @sjr.

Why a ‘Redirect rule’ and not a ‘Page rule’? I do not understand the differences.

As far as I understand after reading

I can create the following Page rule:

Forwarding URL (Status Code: 301 - Permanent Redirect, Url:$2 )

Am I wrong?

Page rules will be deprecated at some point. It is best to create all new redirects in redirect rules.


Thank you, @sjr.

Does it mean that I should replace as soon as possible my existing Page Rules by new Redirect Rules?


I want to create one Redirect Rule to redirect from (non HTTPS version)
to (HTTPS version)
where ‘ANYLABEL’ is the label of the product.

As far as I understand, this is a regex issue. I’ve got a Pro plan in Cloudflare, not sure if I’m allowed to this.

Currently, I’m doing this in Apache .htaccess. However, this involves two 301 redirects:

  1. (performed in the ‘Always Use HTTPS’ of Cloudflare)
  2. (performed in origin’s Apache .htaccess)

Any help is appreciated

Have a look at this:

As your label always starts at the same position and is also the end, you should be able to retrieve it with the substring function.

You can then use the concat function to build your new url.


Thank you @Laudian,

However, I’m still getting two 301 redirects with the subdomain:

1) -->
2) -->

As far as I understand:

  1. The first 301 redirect is due to the fact that I switched on “Always Use HTTPS” in ‘SSL/TLS - Edge Certificates’
  2. The second 301 redirect is a RewriteRule on my origin’s Apache server (htaccess).

Should I switch off the “Always Use HTTPS” in ‘SSL/TLS - Edge Certificates’ and create a new Page Rule (in the second position)?:

- URL: **
- Setting: Always Use HTTPS

And then create another Page Rule (in the very first position, to catch URLs before the ‘Always Use HTTPS’)

- URL:*
- Setting: Forwarding URL (Status Code: 301 - Permanent Redirect, Url:$1/#photos)

I’m aware that I’m losing one of my 20 page rules (Pro account), but it may help me.

Do you see this in a browser or with some other application?

Cloudflare uses https records to tell browsers to always use https, so you really shouldn’t need to worry about https redirects.

This redirect would show up in the browser’s dev console as an internal redirect - 307. This doesn’t actually send a request which then needs to wait for a response before being redirected, the browser just changes the scheme to https.

So you should just keep always use https activated and then create the redirect as you want it.

1 Like

Do you see this in a browser or with some other application?

I see it with any online redirection checker, and also with “curl -v” in my Linux shell.

I’ve just checked again that I had HTTP Strict Transport Security (HSTS) enabled in my Dashboard, with a Max Age Header (max-age) of 6 months (the recommended value). However, I do not see any 307-redirect.

I’ve just checked that ‘Always Use HTTPS’ is also enabled.

If it’s useful, my SSL/TLS encryption mode is Full.

Neither curl nor any online redirect-checkers are browsers, so you can not see an internal-redirect. HSTS does not have any effect on these tools either.

Is it important for you that these tools only show a single redirect , or is the hostname used to display a website in browsers?
Because in that case, I’d recommend you check with your browsers development console (F12, Network tab).

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