How to configure and use URL Rules
About URL Rules
URL rules allow which destination URLs can be used when creating URLs in a project. Let's explore how you can set them up.
1. Setting up your first URL Rule
URL rules are located under your Project > Settings > URL Rules.
1.1 Create a new URL Rule
Click on Create a new URL Rule.
1.2 How to fill the URL Rule form
- Enter a domain for this specific rule to be applied to.
- Example: "stripe.com"
- Enter the list of allowed subdomains separated by a comma.
- Example: "docs,www,blog"
- Enter the list of allowed paths, one on each line.
- Example: "/billing"
- Example: "/payments/checkout"
- Click Save.
1.3 Verify the new URL Rule
You should see the brand new URL Rule listed in your project URL Rules page.
Important notes while creating and using URL Rules
- Each URL Rule is for one Allowed domain. If you need to specify another domain, create another URL Rule.
- URL Rules will be applied per project.
- URL Rules will be applied on new URLs.
- URL Rules will be applied on existing URLs if editing.
- If no Allowed subdomains provided, all subdomains are allowed.
- If no Allowed paths provided, all paths are allowed.
- If no URL Rules specified, all URLs are allowed.
2. Using URL Rules
Once you have created the URL Rule, you can start using it on any of the URL forms.
2.1 Create a new URL
2.2 Filling the form with invalid URL
Let's pretend we fill the form with a URL that does not comply with our predefined URL Rule specifications.
Notice: The form indicates the provided URL is invalid, also gives you the list of allowed paths.
2.3 Filling for form with valid URL
Provide a URL that meets the URL Rule specifications. Then click "Save" with the corrected URL.
This URL meets with the previously created URL Rule:
- Allowed domain "stripe.com"
- Allowed subdomain "docs"
- Allowed path "/billing"
2.4 Verify the brand new URL
The new URL is displayed on the project URLs page.
This time the URL was correctly created because it meets the URL Rule specifications.