Example Use Cases
You would probably need a .forgerc file on your site if you want to reuse pages across different URLs or you want better looking links. This can be achieved with Redirect/Rewrite rules.
Pretty URLs with Rewrite
Create clean, SEO-friendly URLs by rewriting to your actual files:
Location /our-team
Rewrite /our-team.html
External Redirects
Redirect users to external resources while maintaining your URL structure:
Location /terms
Redirect https://docs.google.com/document/d/1_n1_oiyk0b3x7i69n-iAh4f0UmFbvA 302
We imagine you'd want to give a link to your site with terms and conditions. You're too busy at the moment to design specific page, so instead just redirect users to a Google Doc (replace it with your own page, the link will remain the same!).
Direct Response
You don't even need a page, you can write a quick text placeholder directly in the config file:
Location /terms
Respond "Oops! Not ready yet, stay tuned." 200
Custom 404 Pages
Use NotFound condition if you want to display custom 404 page (Forge already supports 404.html out of box, but say you need another name):
NotFound
Rewrite /my-custom-404.html
Single Page Applications
This condition is also useful if you have a single-page application with pushState routing, common in React.js, Vue.js, Angular and many other modern javascript frameworks. In order to make your app work when it refreshes, you need to respond with index.html on any unknown request:
NotFound
Rewrite /index.html
Common Use Cases
These examples demonstrate the most common scenarios where Forge Server configuration is useful:
- URL Cleanup: Remove .html extensions and create pretty URLs
- External Resources: Redirect to external services while maintaining your domain
- Quick Placeholders: Respond with text directly without creating files
- Custom Error Pages: Serve personalized 404 and error pages
- SPA Support: Enable client-side routing for modern JavaScript frameworks
Benefits
Using these configurations provides several advantages:
- Maintain clean, professional URLs
- Improve SEO with better URL structure
- Integrate external services seamlessly
- Create quick prototypes without building pages
- Support modern web applications
- Provide better user experience with custom error handling
Join the Discussion
Have questions or want to share your experience? Join our community discussion to connect with other developers and get help from the Forge team.
Visit Forum Discussion