Table of Contents
- Custom Domain Redirects
- Overview
- Prerequisites
- How It Works
- Step-by-Step Setup
- Step 1: Create .redirects File
- Step 2: Verify Your .pages File
- Step 3: Commit and Push
- Step 4: Activate Redirects
- Step 5: Test Your Redirects
- Redirect Examples
- Simple Page Rename
- Directory Reorganization
- Short URLs
- External Redirects
- Trailing Slashes
- Root to Subdirectory
- Updating Redirects
- Resource Limits
- Troubleshooting
- Error: "Custom domain not configured"
- Error: "No .redirects file found"
- Error: "Redis cache required for redirects"
- Redirects Not Working
- Redirect Shows Instead of Working
- Changes Not Appearing
- Security Considerations
- Limitations
- Advanced Topics
- Complete Example
- Getting Help
- Related Documentation
- Technical Details
Custom Domain Redirects
This guide shows you how to set up URL redirects for your custom domain sites hosted on Bovine Pages Server.
Overview
Redirects allow you to automatically send visitors from one URL to another. This is useful for:
- Renaming pages: Redirect old URLs to new locations
- Short URLs: Create memorable shortcuts to longer paths
- Site reorganization: Update your site structure without breaking old links
- SEO: Maintain search engine rankings when moving content
Important: Redirects only work on custom domains, not standard pages domain URLs (e.g., username.pages.example.com/repository).
Prerequisites
Before setting up redirects, you must have:
- ✅ A repository with a
.pagesfile - ✅ A custom domain configured in your
.pagesfile - ✅ DNS configured and pointing to the Bovine Pages Server
- ✅ Custom domain registered (by visiting your pages URL)
If you haven't set up a custom domain yet, see the Custom Domains wiki page first.
How It Works
When you set up redirects:
- You create a
.redirectsfile in your repository root - You visit
https://your-custom-domain.com/LOAD_REDIRECTSto activate them - Bovine Pages Server reads your redirects and configures Traefik to handle them
- Traefik automatically redirects visitors using 301 permanent redirects
- Redirects are stored persistently in Redis cache
This means:
- ⚡ Fast: Traefik handles redirects directly (no plugin overhead)
- 🔄 Persistent: Redirects remain active until you reload them
- 📊 SEO-friendly: 301 redirects preserve search engine rankings
Step-by-Step Setup
Step 1: Create .redirects File
In your repository root (same level as .pages file), create a file named .redirects:
# Redirect format: FROM:TO
# Lines starting with # are comments
# Empty lines are ignored
# Rename a page
old-page:new-page
# Redirect to a subdirectory
index.html:home/
# Reorganize blog posts
blog/old-post:blog/new-post
# Short URL to long path
docs:documentation/getting-started/
# Absolute URLs (external redirects)
external:https://example.com/page
File Format Rules:
- One redirect per line
- Format:
FROM:TO FROM= URL path to redirect fromTO= URL path or absolute URL to redirect to- Comments start with
# - Empty lines are allowed
- Whitespace around colons is ignored
Step 2: Verify Your .pages File
Make sure your .pages file has a custom domain configured:
enabled: true
custom_domain: www.example.com
Remember: Redirects only work on custom domains!
Step 3: Commit and Push
git add .redirects
git commit -m "Add URL redirects"
git push
Step 4: Activate Redirects
Visit the special activation URL using your custom domain:
https://www.example.com/LOAD_REDIRECTS
Replace www.example.com with your actual custom domain.
You should see a success page with:
- ✅ Confirmation that redirects were loaded
- 📝 List of all active redirects
- 🔄 Instructions for updating redirects
Step 5: Test Your Redirects
Try visiting one of your redirect URLs:
https://www.example.com/old-page
You should be automatically redirected to the new location:
https://www.example.com/new-page
Redirect Examples
Simple Page Rename
Scenario: You renamed about.html to about-us.html
about.html:about-us.html
Visitors to https://www.example.com/about.html are redirected to https://www.example.com/about-us.html
Directory Reorganization
Scenario: You moved all blog posts from /posts/ to /blog/
posts/first-post:blog/first-post
posts/second-post:blog/second-post
posts/third-post:blog/third-post
Short URLs
Scenario: You want a short URL for your documentation
docs:documentation/getting-started/index.html
contact:about/contact-form.html
Now visitors can use:
https://www.example.com/docs→ Full documentationhttps://www.example.com/contact→ Contact form
External Redirects
Scenario: You want to redirect to an external site
github:https://github.com/yourusername
twitter:https://twitter.com/yourusername
donate:https://donate.example.org/campaign
Trailing Slashes
Scenario: You want consistent URL formats
# Redirect to add trailing slash
about:about/
products:products/
# Redirect to remove trailing slash
blog/:blog
docs/:docs
Root to Subdirectory
Scenario: Your main content is in a subdirectory
index.html:app/index.html
/:app/
Updating Redirects
To add, remove, or modify redirects:
- Edit your
.redirectsfile in your repository - Commit and push your changes
- Reload redirects by visiting
https://your-custom-domain.com/LOAD_REDIRECTS
Important: You must reload redirects after every change. They don't update automatically.
Resource Limits
To prevent resource exhaustion, the server admin can configure a maxRedirects limit (default: 25).
This means:
- Maximum 25 redirect rules per domain (default)
- The plugin reads only the first 25 lines of your
.redirectsfile - Contact your admin if you need more redirects
Tip: Use general patterns rather than individual rules when possible.
Troubleshooting
Error: "Custom domain not configured"
Problem: Your .pages file doesn't have a custom_domain field.
Solution:
- Edit your
.pagesfile to addcustom_domain: www.example.com - Commit and push
- Register your custom domain by visiting
https://username.pages.example.com/repository - Try loading redirects again
Error: "No .redirects file found"
Problem: The .redirects file doesn't exist or is in the wrong location.
Solution:
- Create
.redirectsin your repository root (same directory as.pages) - Make sure it's named exactly
.redirects(with the leading dot) - Commit and push
- Try loading redirects again
Error: "Redis cache required for redirects"
Problem: Your Bovine Pages Server isn't configured with Redis.
Solution: Redirects require Redis cache. Contact your server administrator to enable Redis support.
Redirects Not Working
Possible causes:
- Haven't loaded redirects: Visit
https://your-custom-domain.com/LOAD_REDIRECTS - Custom domain not registered: Visit
https://username.pages.example.com/repositoryfirst - DNS not configured: Verify your DNS A/CNAME record points to the server
- Invalid format: Check your
.redirectsfile format (must beFROM:TO) - Too many redirects: Exceeded
maxRedirectslimit (default: 25)
Redirect Shows Instead of Working
Problem: Visiting /LOAD_REDIRECTS shows a file instead of loading redirects.
Cause: You're using the pages domain URL, not the custom domain URL.
Solution:
- ❌ Wrong:
https://username.pages.example.com/repository/LOAD_REDIRECTS - ✅ Correct:
https://www.example.com/LOAD_REDIRECTS
Changes Not Appearing
Problem: Updated .redirects file but changes aren't active.
Solution: You must reload redirects after every change:
- Commit and push your changes
- Visit
https://your-custom-domain.com/LOAD_REDIRECTSagain
Security Considerations
What Redirects Can Do
✅ Allowed:
- Redirect to different pages on your site
- Redirect to external websites (absolute URLs)
- Create short URLs
- Reorganize site structure
❌ Not Allowed:
- JavaScript injection
- HTML injection
- Code execution
- Accessing other users' repositories
Best Practices
- Use 301 redirects: Bovine uses 301 (permanent) redirects automatically
- Avoid redirect chains: Don't redirect A→B→C, instead redirect A→C directly
- Test thoroughly: Verify all redirects work before relying on them
- Document changes: Add comments in
.redirectsexplaining why redirects exist - Clean up old redirects: Remove redirects after sufficient time has passed
Limitations
- Custom domains only: Redirects don't work on
username.pages.example.com/repositoryURLs - Redis required: Your server must have Redis cache enabled
- Manual activation: Must visit
/LOAD_REDIRECTSto load/update redirects - Maximum redirects: Limited by
maxRedirectsconfiguration (default: 25) - 301 permanent: All redirects are permanent (301), not temporary (302)
- No wildcards: Each redirect must be explicit (no pattern matching)
Advanced Topics
Checking Active Redirects
When you visit /LOAD_REDIRECTS, the success page shows all active redirects:
✅ Successfully loaded 3 redirects for www.example.com
Active redirects:
• old-page → new-page
• index.html → home/
• blog/old-post → blog/new-post
Multiple Custom Domains
If you have multiple repositories with custom domains:
- Each repository has its own
.redirectsfile - Each custom domain has independent redirects
- Load redirects separately for each domain
Redirect Priority
If you have overlapping redirects:
- First matching redirect wins
- Order matters in your
.redirectsfile - More specific redirects should come before general ones
Performance Impact
Redirects have zero performance impact on your site:
- Traefik handles redirects at the network level
- No plugin code execution for redirects
- Response time: <1ms for redirects
- Your pages still serve at normal speed
Complete Example
Here's a complete example setup for a blog that was reorganized:
Repository structure:
my-blog/
├── .pages
├── .redirects
└── public/
├── index.html
├── blog/
│ ├── post-1.html
│ └── post-2.html
└── about.html
.pages file:
enabled: true
custom_domain: blog.example.com
.redirects file:
# Blog reorganization - migrated from old structure
# Old homepage
home.html:index.html
# Old blog posts moved from /posts/ to /blog/
posts/my-first-post:blog/post-1.html
posts/getting-started:blog/post-2.html
# Renamed about page
about-me.html:about.html
# Short URLs
contact:about.html#contact
rss:feed.xml
# External social links
twitter:https://twitter.com/myblog
github:https://github.com/myblog
Activation steps:
- Commit files:
git add .pages .redirects public/ && git commit -m "Set up blog with redirects" && git push - Register custom domain: Visit
https://username.pages.example.com/my-blog - Load redirects: Visit
https://blog.example.com/LOAD_REDIRECTS - Test: Visit
https://blog.example.com/posts/my-first-post(should redirect to/blog/post-1.html)
Getting Help
If you encounter issues:
- Check server logs: Ask your administrator to check Traefik logs
- Verify configuration: Ensure
.pageshascustom_domainand custom domain is registered - Test DNS: Use
digornslookupto verify DNS is configured correctly - Read error messages: The
/LOAD_REDIRECTSpage provides detailed error messages - Contact support: Reach out to your Bovine Pages Server administrator
Related Documentation
- Custom Domains - Set up custom domains first
- Quick Start - Basic Bovine Pages setup
- Cache Management - Understanding caching behavior
Technical Details
For administrators and developers interested in the technical implementation:
- Redirects use Traefik's
redirectregexmiddleware - Configuration is stored in Redis with persistent TTL
- Middleware is dynamically generated from
.redirectsfile - All redirects are 301 (permanent)
- Special characters are automatically escaped for regex safety
- Implementation:
redirects.goin the plugin codebase
Note: This feature requires Bovine Pages Server v0.1.1 or later.