将子域重定向到cloudflare上的url

将子域重定向到cloudflare上的url

问题描述:

I need to set up a subdomain to redirect to a specific URL, not another domain. I'm using cloudflare.

I tried to do this by creating an A record pointing to the IP of the server and then I created a Page Rule which redirects from my subdomain to a specific address.

Can anyone help me with this? I'm totally lost, I find information on this anywhere.

thanks

我需要设置一个子域来重定向到特定的URL,而不是另一个域。 我正在使用cloudflare。 p>

我尝试通过创建指向服务器IP的A记录来执行此操作,然后创建了一个从我的子域重定向到特定地址的页面规则。 p>

任何人都可以帮助我吗? 我完全迷失了,我在任何地方都能找到相关信息。 p>

谢谢 p> div>

Maybe it will be easier to make redirection with rewrite rules through .htaccess or virtual host configuration?

  • At Cloudflare CP: create A record for subdomain in DNS section (if you don't have * A record already)
  • At webserver: configure virtual host or/and add rewrite rules to redirect to needed URL

There is a fairly extensive tutorial about PageRules in our knowledge base & on our blog.

Note: You do need to make sure the DNS record is proxied in your DNS settings for it to work. Redirects won't work if the record is going direct to your server.

I suspect there's a bug on cloudflare ( I already reported it ) If you have your subdomain record in place along with orange cloud proxy active and the correct url pattern and forwarding address set and it still refuses to work, then you are experiencing the -still to be confirmed- bug.

This quick fix did the trick for me:

  1. Go to cloudflare settings.
    domain settings contextual menu on cloudflare
  2. Change the "CDN only" performance setting to "CDN + basic optimizations".
    contextual menu for performance settings and mouse indicating selection

It will start working immediately, after that you can go back to "CDN only" and it will continue to work.