How Do I Set Up a 301 Redirect in Cloudflare?

  • Thread starter CampFireJack
  • Start date
CampFireJack

CampFireJack

New Member
Joined
May 9, 2021
Messages
11
Reaction score
0
Points
1
  • #1
I have a bunch of pages on my website that I no longer want to have indexed in Google. For a variety of reasons, I can't delete them. I no longer want them though and I fear that if I stop linking to them, they'll remain live pages, but orphan pages. What I'd really like to do is have these pages redirect to a single page that I recently created. This newly created page has PHP code on it that returns a 410 header. I'll keep all of these pages linked to, but once they're all out of the index, I'll remove the links. This is the only thing I think I can do to get rid of them. It's my CMS's fault, not mine.

Anyway, I can either write a 301 redirect in my .htaccess file or I can do it in Cloudflare. I think Cloudflare is easier, but I'm not sure how to go about it since I've never set anything up like that before. Can anyone offer any advice?
 
JodyBuchanan

JodyBuchanan

New Member
Joined
May 10, 2021
Messages
11
Reaction score
0
Points
1
  • #2
What you're looking for in Cloudflare is called a Page Rule. Or Page Rules. There are many different types of rules you can use for your site and in some cases, they're fairly simple to configure. Of course, since these things are custom, you can get as complex as you want, but for your uses today, I think the setup will be straightforward. Examples of page rules in Cloudflare are Always Online, Always Use HTTPS, Auto Minify, Automatic HTTPS Rewrites, Browser Cache TTL, Browser Integrity Check, and many more. Today I'll be focusing on the Forwarding URL rule.

To forward (or redirect) a URL with page rules in Cloudflare, log into your account and then choose the site that's got the pages you'd like to forward. Then, click the Rules link up in the top navigation bar.

cloudflare-page-rules-link.gif

On the Page Rules page, you'll see how many rules you have left. With a free account, you only get three. You'll need to upgrade if you want more.

To start off, click the Create Page Rule button.

cloudflare-create-page-rule.gif

After you do that, you'll see some fields to fill in.

cloudflare-create-page-rule-settings.gif

Start off by filling in the URL or URLs that you'd like to redirect. For instance, if you want to redirect https://example.com/bad-page.html, place that URL into the first field. If you'd like to redirect everything in a directory, such as https://example.com/bad-pages/*, then follow my lead and input the base domain name, plus the directory where the bad pages are located, and then an asterisk to indicate a wildcard. This wildcard will tell Cloudflare that everything in the directory (or everything within that directory structure) should be redirected to another URL.

Next, from the drop-down, choose Forwarding URL.

cloudflare-forwarding-url-selection.gif

From the Status Code drop-down, choose your method of redirection. In your case, I would recommend a 301 redirect, since it's permanent. After that, input the page you wish to redirect to.

cloudflare-completed-page-rule-forwarding-url.gif

As you can see, I made up a sample URL for you to redirect to. You'd want to fill that bottom field in with wherever your 401 page is located.

After you're finished filling everything in, click the Save and Deploy button and you should be all set. After a few seconds, all of those bad pages should redirect to one that returns a 410 header code for Google to pull out of its index.
 
How Do I Set Up a 301 Redirect in Cloudflare? was posted on 05-17-2021 by CampFireJack in the Servers & Hosting forum.

Forum statistics

Threads
88
Messages
156
Members
17
Latest member
mandy cromarty
Looking for an all-around awesome forum? Check out IndyFor!
Top