Skip to content

Collection

In SwitchHoster, a collection is the core unit that manages multiple matches. It unifies related rules and configurations into a whole. Each collection consists of describe, URI matching rules, and match. At the same time, you can perform operations on the collection, such as editing, deactivating, or deleting, etc.

URI match rule list

SwitchHoster provides a variety of flexible URI matching rules to adapt to different usage scenarios:

RulesUsage scenarios
defaultbase domainExpected to match a domain name and all its subdomains.
hostnameExpected to strictly match a subdomain.
starts-withExpected to match 'URL' at the beginning of a specific string or path
regexExpectations require complex pattern matching when
exactWhen exact match is expected
neverExpect some URIs to never match

Describe

Describe section defines the name and description of the collection so that you can better manage and apply the collection.

  • Name: Provides a concise name for the current collection, which makes it easy to distinguish or select different collections in the collection list.
  • Description: Provides a detailed text description of the current collection, usually including the usage scenario, purpose, applicable task or website of the collection, etc. Help you and other users understand the role and configuration details of the collection.

URI Match rules

A collection can have one or more URI (Uniform Resource Identifier) matching rules, the URI can be the address of the URL, the server IP address, etc.

Introduction

The URI consists of scheme (protocol), hostname, port, path, and query string.

TIP

In switchhoster, it is not sensitive to scheme(protocol). You can choose whether to add scheme (protocol) according to the actual usage.

uri-match-rules

Default

base-domain match rule is the default matching rule

Base domain

When the URI matching rule is set to base-domain, if the top-level domain name and second-level domain name of the matching URI are successfully matched, all matches will take effect.

For example, if the URI is https://domain.com using the base-domain match rule:

URIWas the match successful?
http://domain.com
https://www.domain.com
https://example.com
https://domain.net

Hostname

When the URI match rule is set to hostname, the specified hostname and port are matched exactly. This rule is useful when you need to be strictly limited to a specific subdomain.

TIP

Port is an optional item. If it is filled in, it will be strictly matched.

For example, if the URI is 'https://sub.domain.com:3000 'and the host match rule is used:

URIWas the match successful?
http://sub.domain.com:3000
https://sub.domain.com:3000/page.html
https://sub.domain.com
https://sub.domain.com:4000
https://sub2.domain.com:3000

Starts with

When the URI matching rule is set to start with, matches a URI that starts with the specified string or path, and all matches in the collection will take effect regardless of the subsequent content.

For example, if the URI ishttps://sub.domain.com/path/, and when using starts with to match a rule:

URIWas the match successful?
https://sub.domian.com/path/
https://sub.domain.com/path/page.html
https://sub.domain.com:3000/path/page.html (excess ports)
https://sub.domain.com/path (missing/
https://www.domain.com/path/

Regular expression

When the URI matching rule is set to regular expression, the regular expression you write will be used to match the detected resource, and if the match is successful, all matches will take effect.

WARNING

Regular expressions are an advanced option, and collections can take effect on unexpected pages if used improperly.

For example, if the URI is^.*domain\.com,and when using regular expression to match the rule:

URIWas the match successful?
https://www.domain.com
https://sub.domain.com/path/page.html
https://domain.com
https://example.com

Exact

When the URI match rule is set to exact, it will strictly match the complete URI, including scheme (protocol), hostname, port, path, and query string, if identical all matches will take effect.

For example, if the URI ishttps://www.domain.com/page.html, and when using the exact match rule:

URIWas the match successful?
https://www.domain.com/page.html
http://www.domain.com/page.html
https://www.domain.com/page.html?query=123
https://www.domain.com/

Never

When the URI match rule is set to never, detection of the current URI is skipped.

For example, it is desirable to temporarily cancel the current URI matching rule, but do not want to delete it.

Operations

The Operations section contains the basic functions for managing collections, which allow you to save, disable, or delete collections as needed.

  • Delete: Completely removes the current collection, including all matches and configurations within it. This operation cannot be withdrawn, please proceed with caution.
  • Disable: temporarily deactivates the current collection and keeps the collection configuration unchanged so that it can be enabled again in the future.
  • Enable: Re-enable the current collection and restore the collection configuration.
  • Discards: Discards all modifications to the collection and matching items and returns to the collection list interface.
  • Save: Saves all changes to the collection and matches, ensuring that the current edits are updated.