Cloudflare Redirects: How to Setup 301 Redirects (URL Forwarding) Using ...

So you have a super popular "how to poop standing up" article šŸ’©, butt you just got a new domain hooked up on CloudFlare and are worried that all those people who bookmarked the old URL might not be able to find thew new one...

Sounds like you need to setup some 301s!

Unfortunately, setting up a 301 redirect at CloudFlare isnā€™t that self-explanatoryā€¦

And since nobody likes reading documentation I figured that a true hero needed to step up and make this easy on the rest of the world.

So here I am, hero of the internet, come to make your life easier once again ā€“ with an article, video & SOP for you to save and use later!

--

āœ”ļø Checklist/SOP: https://devin.to/ps-cloudflare-redirects

--



How to setup a CloudFlare 301 redirect using ā€œpage rulesā€:

The process of setting up redirects using Cloudflareā€™s DNS is pretty simple. You add your domain, point the CloudFlare DNS records (A record & CNAME record) to Cloudflareā€™s server, and then setup a URL forwarding rule. Thatā€™s pretty much it.

The first two steps of this walkthrough have nothing to do with the actual CloudFlare 301 setup. They are the things you need to do before any of this works. So, if youā€™ve already added your domain to your CF account and pointed your domain registrarā€™s nameservers to it ā€“ you can skip them and start at Step 3.

1. Add Domain to CloudFlare

At the dashboard (dash.cloudflare.com) of your CloudFlare account click the ā€œAdd a siteā€ button, and enter your domain on the next screen.

Once you do that, youā€™ll be presented with pricing options. Just choose the free one (bottom of screen) and move on.

Cloudflare will scan for existing DNS records and bring them over.

Keep them or delete them ā€“ the choice is yours (and depends on what youā€™re trying to do).

Click continue, and youā€™ll get your accountā€™s nameservers.

Youā€™ll need to update your current domainā€™s nameservers, which you can find at the domain registrar ā€“ aka the place where you login to see your domain, and probably where you purchased it.

2. Update NameServers

I canā€™t make a tutorial for updating nameservers at every web hosting company, because thereā€™s like a trillion of them.

But youā€™ll just need to go to your account > select your domain > choose ā€˜edit nameserversā€™ or something similar > paste in the nameservers that Cloudflare gave you in the last step.

Now, it will take anywhere from 10 minutes to 48 hours for those changes to take effect. This is called propagation.

But you donā€™t have to wait for that to continue. You will have to wait for it for all the things you do next to work, however.

3. Update CloudFlare DNS

This is where the actual process starts.

Go to your domain settings in CloudFlare and choose ā€œDNSā€.

If redirecting the whole domain I usually start with deleting the current DNS records that CloudFlare ported over. Donā€™t do that if you have records in there you need.

Yes, captain obvious I know butā€¦ Common sense isnā€™t always so common in these extremely tense IT settingsā€¦

Next, weā€™re going to add in the CloudFlare DNS records you need for your URL Forwarding to work.

Click ā€˜Add recordā€™ and add the following information, and click the ā€˜Saveā€™ button:

  • Type: A
  • Name: @
  • IPv4 Address: 192.0.2.1

Now, click the ā€˜Add recordā€™ button again, add the following information, and click the ā€˜Saveā€™ button:

  • Type: CNAME
  • Name: www
  • Target: @

4. Setup Page Rules for URL Forwarding

Navigate to the ā€œRulesā€ area on the sidebar, then click ā€œPage Rulesā€ and click the ā€˜Create Page Rule` button.

Now itā€™s time to set your 301s!

Iā€™m going to setup a 301 redirect to forward all traffic coming to ā€˜domain Aā€™ to ā€˜domain Bā€™, but you can easily just change the URL & destination to fit your needs.

Follow these steps:

  1. Enter the URL pattern you want 301ing
  2. Click the dropdown and choose ā€˜URL Forwardingā€™
  3. Select your ā€˜Status Codeā€™ from the drop down (probably 301)
  4. Enter the destination
  5. Click ā€˜Save and Deploy Page Ruleā€™

I entered the root domain, and put an asterisk ( * ) at the end, which means that if anyone goes to an inner url, like ā€œdomain.com/whatever-asdfadfā€ it will also get redirected.

You can setup inner URL specific 301s too.

Now, Iā€™m simply going to do the exact same thing again ā€“ but this time add the www. version.

Same steps from above:

  1. Enter the URL pattern you want 301ing
  2. Click the dropdown and choose ā€˜URL Forwardingā€™
  3. Select your ā€˜Status Codeā€™ from the drop down (probably 301)
  4. Enter the destination
  5. Click ā€˜Save and Deploy Page Ruleā€™

Thatā€™s it! Youā€™re done!

You should be able to go to your forwarded domain, and be taken to the destination.

If it doesnā€™t work, make sure:

  1. Youā€™ve given enough time for your nameservers to propagate (see step #2)
  2. You clear the CloudFlare cache (if you transferred your domain from another Cloudflare account)
  3. You clear your browser cache, or try in ā€˜incognito modeā€™ (press shift + command + n on most browsers (MAC) to open an incognito window)

šŸŽ Free Gifts

šŸ‘‰ Get the free How to setup a Cloudflare 301 Redirect checklist, and run it anytime you need to repeat this process.



#cloudflare #seo #redirects #301redirects #urlforwarding #cloudflaretutorial #seotips

Comments

Popular posts from this blog

How To Be Successful: AVOID LUCK at All Costs! [CRITICAL You Understand...

Audio Diffusion: AI Sample Generation + Free Text-to-Audio AI Model