Sebelum memulakan lab ini, pastikan anda sudah:
- ✅ Domain sudah configured di Cloudflare (dari Lab 23-25)
- ✅ Cloudflare account active
- ✅ Access ke Cloudflare Dashboard
Dalam lab ini, anda akan belajar:
- Memahami Cloudflare Page Rules
- Buat subdomain baru untuk forwarding
- Configure forwarding rule di Cloudflare
- Setup DNS record untuk subdomain
- Test redirect berfungsi dengan betul
- Explore limits dan best practices
Cloudflare Page Rules membenarkan anda configure behavior khusus untuk URLs tertentu.
Keupayaan:
- ✅ Forwarding URL (redirects)
- ✅ Custom caching
- ✅ Security settings
- ✅ SSL settings
- ✅ Performance optimization
Untuk lab ini, kita fokus pada Forwarding URL.
User → wp.domain.com
↓
Cloudflare: "Permanently moved to wordpress.org/download/"
↓
User browser → wordpress.org/download/
↓
Address bar: wordpress.org/download/
Ciri-ciri:
- Permanent redirect
- Search engines update index
- Browser cache the redirect
- Best untuk permanent moves
User → wp.domain.com
↓
Cloudflare: "Temporarily at wordpress.org/download/"
↓
User browser → wordpress.org/download/
↓
Address bar: wordpress.org/download/
Ciri-ciri:
- Temporary redirect
- Search engines keep original URL
- Not cached aggressively
- Best untuk temporary situations
| Feature | 301 (Permanent) | 302 (Temporary) |
|---|---|---|
| SEO | Transfer ranking | Keep original ranking |
| Cache | Heavily cached | Less cached |
| Use Case | Domain migration, permanent moves | Maintenance, A/B testing |
| Reversible | Difficult (cached) | Easy |
Untuk lab ini, kita akan guna 301 kerana ini adalah permanent forward.
| Plan | Page Rules Limit |
|---|---|
| Free | 3 rules |
| Pro | 20 rules |
| Business | 50 rules |
| Enterprise | 125 rules |
Important: Free plan hanya dapat 3 Page Rules. Guna dengan bijak!
- Prioritize: Guna untuk redirects paling penting sahaja
- Combine: Guna wildcard untuk cover multiple URLs
- Alternative: Guna Bulk Redirects (Beta) untuk more redirects
Sebelum buat Page Rule, kita perlu setup DNS record dahulu.
- Pergi ke https://dash.cloudflare.com
- Login dengan account anda
- Pilih domain anda dari dashboard
- Click tab DNS di menu sebelah kiri
- Anda akan nampak senarai DNS records sedia ada
Click Add record
Masukkan maklumat:
| Field | Value | Keterangan |
|---|---|---|
| Type | A |
Record type |
| Name | wp |
Subdomain name |
| IPv4 address | 192.0.2.1 |
Dummy IP (akan redirect sebelum sampai server) |
| Proxy status | ☁️ Proxied (orange cloud) | PENTING: Mesti proxied! |
| TTL | Auto |
Automatic |
PENTING Notes:
- ✅ Proxy status MESTI Proxied (orange cloud) - Page Rules hanya berfungsi dengan proxied records
- ✅ IP address boleh guna dummy IP seperti
192.0.2.1kerana traffic akan di-redirect sebelum sampai server - ✅ Atau boleh guna server IP anda (54.x.x.x) sebagai fallback
Click Save
Anda sepatutnya nampak record baru:
Type Name Content Proxy Status
A wp 192.0.2.1 Proxied (orange cloud)
Tunggu 1-5 minit untuk DNS propagate.
Semak propagation:
dig +short wp.domain.comExpected: Cloudflare IPs (104.x.x.x atau 172.x.x.x)
Atau check online: https://dnschecker.org
- Di Cloudflare Dashboard, click tab Rules di menu kiri
- Click Page Rules
- Atau pergi ke: Rules → Page Rules
Di bahagian atas page, anda akan nampak:
Page Rules (X/3)
X = Berapa rules yang dah digunakan
Jika sudah 3/3, anda perlu delete satu rule untuk tambah yang baru.
Click Create Page Rule button
Di field If the URL matches:
Masukkan:
wp.domain.com/*
Ganti domain.com dengan domain anda!
Penjelasan pattern:
wp.domain.com- Subdomain anda/*- Wildcard untuk match semua paths
Contoh URLs yang akan match:
- ✅
wp.domain.com/ - ✅
wp.domain.com/anything - ✅
wp.domain.com/path/to/page
-
Click dropdown + Add a Setting
-
Pilih Forwarding URL
-
Anda akan nampak 2 fields:
Status Code:
- Pilih: 301 - Permanent Redirect
Destination URL:
- Masukkan:
https://wordpress.org/download/
PENTING: Pastikan URL lengkap dengan https://
Page Rule anda sepatutnya nampak macam ini:
If the URL matches:
wp.domain.com/*
Then the settings are:
Forwarding URL: 301 - Permanent Redirect
Destination URL: https://wordpress.org/download/
- Review semua settings
- Click Save and Deploy button
- Rule akan active dalam beberapa saat
Di Page Rules list, anda akan nampak rule baru:
Rule 1: wp.domain.com/*
Status: Active (toggle should be ON)
Forwarding URL: 301 to https://wordpress.org/download/
Tunggu 10-30 saat untuk rule propagate ke Cloudflare edge servers.
- Buka browser
- Clear cache atau guna Incognito mode
- Pergi ke:
https://wp.domain.com
Expected result:
- ✅ Browser automatically redirect ke
https://wordpress.org/download/ - ✅ Address bar berubah ke
wordpress.org/download/ - ✅ WordPress download page loaded
- ✅ Redirect sangat cepat (instant, dari Cloudflare edge)
Test dengan paths berbeza:
https://wp.domain.com/→ redirectshttps://wp.domain.com/test→ redirectshttps://wp.domain.com/any/path→ redirects
Semua sepatutnya redirect ke same destination!
Pergi ke: http://wp.domain.com
Expected:
- ✅ Automatic redirect ke
https://wordpress.org/download/ - ✅ Works untuk HTTP dan HTTPS
# Test redirect
curl -I https://wp.domain.comExpected output:
HTTP/2 301
location: https://wordpress.org/download/
server: cloudflare
cf-cache-status: DYNAMIC
Perhatikan:
- Status:
301(Permanent Redirect) location:header tunjuk destinationserver: cloudflare(redirect handled at edge)
# Follow redirect dan lihat final destination
curl -L -I https://wp.domain.comExpected output:
HTTP/2 301
location: https://wordpress.org/download/
HTTP/2 200
server: nginx
content-type: text/html
✅ Perfect! Redirect berfungsi dengan betul!
Jika anda ada lebih banyak Page Rules available, anda boleh buat multiple redirects.
Langkah 1: Tambah DNS Record
Di Cloudflare DNS:
Type: A
Name: github
IPv4 address: 192.0.2.1
Proxy: Proxied (orange cloud)
Langkah 2: Create Page Rule
URL Pattern: github.domain.com/*
Setting: Forwarding URL
Status Code: 301 - Permanent Redirect
Destination: https://github.com/your-username
Langkah 3: Save dan Test
curl -I https://github.domain.com
# Should redirect to github.com/your-usernameDNS:
Type: A
Name: linkedin
IPv4: 192.0.2.1
Proxy: Proxied
Page Rule:
URL: linkedin.domain.com/*
Forward: 301 to https://linkedin.com/in/your-profile
Page Rules (3/3)
1. wp.domain.com/* → wordpress.org/download/
2. github.domain.com/* → github.com/your-username
3. linkedin.domain.com/* → linkedin.com/in/your-profile
Buat easy-to-remember links:
twitter.domain.com → twitter.com/username
fb.domain.com → facebook.com/page
ig.domain.com → instagram.com/profile
docs.domain.com → gitbook.com/docs
help.domain.com → zendesk.com/support
api.domain.com → swagger.io/api-docs
download.domain.com → github.com/releases/latest
app.domain.com → apps.apple.com/app-id
promo.domain.com → domain.com/?utm_source=promo
blackfriday.domain.com → domain.com/sale
shop.domain.com → amazon.com/shop/affiliate-id
store.domain.com → shopify-store.com?ref=code
register.domain.com → eventbrite.com/event-id
webinar.domain.com → zoom.us/meeting-id