File Format and Structure
Above is an example of a config file with a few Conditions and Rules.
Configuration File Structure
Our config file allows to specify how site requests will be handled. The general structure of a file is:
[Condition#1] [args]
[Rule#1] [args]
[Rule#2] [args]
Supported Conditions
So far these conditions are supported:
- Location: Supports exact path or express-like wildcards
- NotFound: Handles 404 error conditions
Note: Additionally, any plugin can define its own rules or conditions (more on that to follow).
Configuration File Formats
Forge Server supports multiple configuration file formats:
- .forgerc: Preferred format (no extension)
- forgerc.txt: Text format
- forgerc.json: JSON format
File Structure
The configuration file should be placed in the root of your project and follows a hierarchical structure:
- Conditions: Define when rules should be applied
- Rules: Specify what actions to take
- Arguments: Provide parameters for conditions and rules
Location Condition
The Location condition allows you to match specific URL paths:
- Exact paths: Match specific URLs exactly
- Wildcards: Use express-like patterns for flexible matching
- Pattern matching: Support for complex URL patterns
NotFound Condition
The NotFound condition handles 404 error scenarios:
- Custom 404 pages: Serve custom error pages
- Error handling: Define specific error responses
- Redirect logic: Redirect users from missing pages
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