Best way to do 301 redirect on subdomain

I have a subdomain that I want to setup a 301 redirect to the main domain. I want that domain to go to …Page rules do not work…I have tried everything, using proxy and all. Nothing seems to work. Can someone please help me?

Can you give the domain and subdomain?

yes action.nolabels. org and I want it to forward to nolabels. org

action.nolabels.org currently CNAMEs to Cloudfront at d3e77ewrarv1tp.cloudfront.net

You want to replace that? If so, you will need to delete the CNAME record, add an A record pointing to 192.0.2.1 action (make sure it is proxied), then your redirect should work if it’s correctly set up.

Redirecting it to nolabels.org will then redirect again to www.nolabels.org (CNAMEs to www.nolabels.org.cdn.rebelmouse.com), is that your aim?

1 Like

I just want when people to go to action. nolabels. org to get a 301 redirect to the main nolabels. org…how can I do that…page rules was not working :frowning:

Then do what I suggested.

Delete the existing CNAME and add an A record for action pointing to 192.0.2.1 and ensure it is proxied.

(The current CNAME is not proxied and so the request doesn’t reach Cloudflare so the redirect can never happen).

Assuming the redirect is set up correctly, it should then happen.

1 Like

just did that and I get the “your site cannot be found” error

Working OK for me. Page loads in a browser and redirects happen…

curl -I https://action.nolabels.org
**HTTP/2 301**
date: Mon, 13 Nov 2023 21:06:04 GMT
**location: https://nolabels.org**
cache-control: max-age=3600
expires: Mon, 13 Nov 2023 22:06:04 GMT
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=pr4pctyO6uy3R9E0QSpB0B8BYRWOxcwPj6d8awiSD8KrvtglZUr7HPegWwFslt8Uv%2F%2Fro7GtyV3x%2F1l1coYV4qvO4LCGFaIoo%2BU%2FXRMlErVHDDQ%2FxkyNmhxZ%2FDPCl1UEK0Sgw3dA"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 8259f9fb2ddb6401-LHR
alt-svc: h3=":443"; ma=86400

curl -I https://nolabels.org
**HTTP/1.1 301 Moved Permanently**
Server: openresty
Date: Mon, 13 Nov 2023 21:06:16 GMT
Content-Type: text/html
Content-Length: 166
Connection: keep-alive
**Location: https://www.nolabels.org/**

curl -I https://www.nolabels.org
**HTTP/2 200**
server: nginx
content-type: text/html; charset=utf-8
cache-control: public, max-age=0
cache-tag: long_cache_articles/25318866,section/2224365851,section/0-25318866,section/588372768,section/2235420434
cloudflare-cdn-cache-control: max-age=3700, stale-while-revalidate=2592000, stale-if-error=87600
etag: "cad92212445b579c34a5b0c7165c44fa"
1 Like

You haven’t yet changed the DNS records as suggested by @sjr, right? You’ll need to do that, and make sure your subdomain A record is :orange: proxied. Then you’ll need to wait until the DNS change fully propagates. DNS Checker - DNS Check Propagation Tool

1 Like

Ok i did all of this…officially made the changes…waited about 30 mins…still not working…can you all see on your end if it looks good?

Works fine for me. Page is OK in browser and redirects are working…

Connecting to 104.21.28.243 for action.nolabels.org...
Received HTTP redirect code 301, absolute redirect to https://nolabels.org
Connecting to https://nolabels.org...
Received HTTP redirect code 301, absolute redirect to https://www.nolabels.org/
Connecting to https://www.nolabels.org/...
Connected with HTTP code 200.

I use the url https:// action . nolabels. org and it fails?

ok I keep testing, sometimes it loads properly, sometimes it does not?

Note that only action.nolabels.org is proxied through Cloudflare, www.nolabels.org and nolabels.org are not so maybe there’s something on those origin handled requests that are blocking you.

dig +short action.nolabels.org
104.21.28.243
172.67.147.233

dig +short nolabels.org
54.243.223.182
54.243.223.181

dig +short www.nolabels.org
www.nolabels.org.cdn.rebelmouse.com.
n.sni.global.fastly.net.
151.101.1.91
151.101.65.91
151.101.129.91
151.101.193.91

Does going to www.nolabels.org work for you?
Does going to nolabels.org work for you?

Hi…the A records for nolabels .org are both in cloudflare…but are not proxied…I can go to nolabels .org and go to www . nolabels .org and they both work…any advice?

Check you haven’t added any WAF rules that are blocking yourself, although you would expect a page to be shown for that so unlikely.

can anyone help? this is not working properly…I cant seem to figure this out