The Web Rules feature in Cloudways provides an intuitive interface for managing application traffic behavior directly from the platform.
It is designed to simplify server configuration by allowing users to manage redirects, rewrites, and HTTP headers without the need to manually edit complex server configuration files like .htaccess via SSH or SFTP.
This functionality was introduced as part of Cloudways' transition towards the high-performance Lightning Stack, offering a modern, faster, and simpler approach to configuration management. However, it is also available for the Hybrid Stack.
IMPORTANT ANNOUNCEMENT
The Web Rules feature is currently in public preview
Public previews are preliminary releases of products and features that are ready for broader testing and usage as part of an incremental roll-out strategy.
Public previews may track and measure SLAs but do not back them by issuing credits. Public previews follow our standard retirement process. All offerings follow our standard pricing and billing procedures, and modified pricing for previews is subject to change.
We expect but do not guarantee that public previews perform for production-level workloads. We recommend using simulated test data and not running sensitive workloads on public preview products.
Table of Contents:
What Are Web Rules?
Web Rules allows you to create and manage your application's traffic behavior. By allowing users to easily modify response headers and configure redirect or rewrite rules directly from the platform.
They enable you to:
Add, modify, or remove HTTP response headers ( i.e. Modifying cache-control headers and security headers)
Redirect URLs (e.g., from one domain or page to another)
Rewrite URLs internally for routing
This functionality was introduced to reduce the need for direct .htaccess edits when using the Hybrid Stack., which requires navigating through SSH/SFTP clients, often leading to confusion or errors that could affect performance or site stability, making it easier and safer to configure through the Cloudways Platform UI.
Key Features of Web Rules
Web Rules enable three primary types of traffic and response control: Header Rules, Redirect Rules, and Rewrite Rules.
Header Rules
Header rules are used to modify the HTTP response headers sent by your application's server. They are essential for controlling caching behavior and enhancing application security.
You can use Header Rules to:
Modify Caching: Adjust
cache-controlheaders to better manage how browsers store your content.Improve Security: Apply critical security headers such as HSTS (
Strict-Transport-Security), Content Security Policy (CSP), orX-Frame-Options.Customize Headers: Add custom headers (e.g.,
X-CDN: false) or remove unwanted headers (e.g.,VaryorSet-Cookie).Mask Information: Hide response headers like the
Serverheader for enhanced security.
Example: To enforce HTTP Strict Transport Security (HSTS) for two years:
Header:
Strict-Transport-SecurityValue:
max-age=63072000; includeSubDomains; preloadAction:
Set
Redirect and Rewrite Rules
These rules allow you to control how incoming URLs are handled and routed.
Redirects
A redirect sends the client (the user's browser) to a completely new URL or location. The user's address bar will change to show the new destination.
Redirects support two main actions:
Permanent Redirect (301 Status Code): Informs the client and search engines that the content has permanently moved. This is the standard best practice for SEO when changing a page's URL.
Temporary Redirect (302 Status Code): Informs the client that the content has temporarily moved. This is ideal for short-term changes or A/B testing.
Common Redirect Use Cases:
Redirecting traffic between domains (e.g.,
www.domain.comtodomain.com).Moving an old page to a new one (e.g.,
/old-pageto/new-page).Redirecting a page to a completely different domain (e.g.,
/hellotohttps://hello.com).
Internal Rewrites
An internal rewrite modifies the requested URL path on the server without changing the URL visible in the user's browser. For example, a request for /page-1 may be internally rewritten to /page-2.
The user still sees /page-1 in their browser, but the content of /page-2 is returned. This is commonly used for clean URL structures or application routing.
Conditional Rules
Redirect and Rewrite Rules allow you to define a single condition that must be met before the rule is executed. This conditional logic can be based on parameters such as:
Hostnames
Country codes
Device codes
Specific URLs or patterns
Example: A conditional rule can redirect all visitors from Europe to a localized landing page, such as https://www.example.com/eu.
Choosing the Correct Redirect Status Code
301 – Permanent Redirect:
Use when a URL or domain change is permanent. Search engines transfer SEO value to the new destination.302 – Temporary Redirect:
Use when the redirect is temporary (for example, location-based routing, testing, or short-term campaigns). Search engines continue indexing the original URL.
Always use 301 for canonical and permanent redirects, and 302 only when the redirect behavior is temporary.
Limitations and Webstack Recommendations
To maintain optimal performance and stability, certain limits apply to Web Rules. These limitations should guide your choice between using the Lightning Stack with Web Rules and the Hybrid Stack with .htaccess.
Rule Limitations:
Rule Type | Maximum Allowed (Per Application) | Conditions |
Header Rules | 10 | — |
Redirect/Rewrite Rules | 25 | Limited to one condition per rule |
Note: If your application requires more than 25 rewrite/redirect rules or necessitates multi-condition logic, Cloudways recommends using the Hybrid Stack and managing these configurations via .htaccess (HTXS).
Webstack Recommendation:
Scenario | Recommendation |
No .htaccess requirements | Lightning Stack |
< 25 Redirects/Rewrites OR < 10 Header Rules (or both) | Lightning Stack + Web Rules |
25+ Redirects/Rewrites OR 10+ Header Rules (or both) | Hybrid Stack + .htaccess |
Complex, multi-condition, or nested rules | Hybrid Stack |
Key Takeaway: Web Rules simplifies common server configuration on the Lightning Stack. However, the Hybrid Stack remains available for specialized, high-volume, or complex rule requirements.
Performance & Best Practices
For optimal performance and stability:
Avoid creating more than the recommended 25 redirect/rewrite rules.
Limit complex or chained conditions.
Always test your new rules immediately after applying them to ensure your application behaves as expected.
Use the Hybrid Stack if your project depends on advanced, complex
.htaccesslogic.
Steps To Create and Manage Web Rules
This section provides the necessary steps to access the Web Rules interface and create both Header and Rewrite Rules.
Step #1: Accessing the WebRules Interface
Log in to your Cloudways Platform.
From the left-hand navigation panel, click My Applications to view all applications linked to your account.
Step #2: Navigate to your application management
From the list of applications, select the specific application for which you want to create or manage Web Rules.
Step #3: Go to Web Rules
Within the selected application's settings, locate and click the Web Rules option. This section will be your central hub for rule management.
This section allows you to create, edit, or manage rules that control web traffic behavior for the application.
Step #4: Select Web Rule Type
Webrules is categorized into two tabs:
Header Rules
Rewrite Rules
By default, you will be navigated to header rules and and will be able view all existing rules listed (if added any).
Header Rules
Create header Rules
To create a new header rule, click Add Header Rule.
After clicking Add Header Rule, a configuration panel will appear. Fill out these fields to set a new header:
Rule Type: Choose Custom to manually define a specific behavior. Alternatively, use pre-built templates for quicker setup.
Action: Choose Set to assign or modify a header's value or Unset to remove the header from response.
Header Name: Enter the exact name of the HTTP header you want to affect (e.g.,
Strict-Transport-Security).Value: Specify the value that should be applied to the selected header.
Always Apply: Enable this option if the rule should apply to all relevant requests without any conditional restrictions.
Review and Apply: Review all details. Once correct, click Add Rule in the top-right corner of the page to save and apply the rule.
After configuring your custom rule , review all the entered details. Once everything looks correct, click Add Rule at the top-right corner of the page to save and apply the new rule to your application.
After the rule is created, it will appear in the list of existing rules.
Delete Header Rules
To remove a rule, click the three-dot menu next to it and select Delete.
A confirmation pop-up will appear. Click Delete to confirm and permanently remove the rule.
Edit Header Rules
To edit a rule, click the three-dot menu next to it and select Edit.
Edit the relevant configuration and click on Update Rule.
Rewrite Rules
Create Rewrite Rules
To create a Rewrite rule, navigate to the Rewrite Rule tab, click Add Rewrite Rule.
After clicking Add Rewrite Rule, a configuration panel will appear where you can define the parameters and conditions for your new Web Rule.
Action: Determines the rule's outcome. Choose one of the following:
Permanent Redirect (301): Best for permanent URL changes and SEO.
Temporary Redirect (302): Ideal for temporary changes or testing.
Rewrite: Modifies the URL path internally without changing the URL the user sees.
Keep or Discard Original Query String:
True: Preserves any original query parameters (e.g.,
?source=email).False: Removes any original query parameters.
Source: Enter the exact URL or pattern that should trigger the rule (e.g.,
/old-page).Destination: Specify the target URL or path where the request should be routed (e.g.,
/new-page or a full external URL).Attach Condition (Optional): Apply the rule only if a specific condition (like hostname, country, or device) is met. Leave this field blank to apply the rule universally.
Following parameters are supported for conditional redirects:
Condition | Purpose |
URI | URI to match in source. EX: /randompage |
QUERY_ARG | Query arg to match in source. EX: no-cache do not preface with the query indicator |
HOST | http_host tp match in request EX: www.domain.com |
COUNTRY CODE | ISO Country code. Uses MaxMind’s GeoIP database. EX: US |
DEVICE CODE | Device detection code, uses nginx map headers. EX (desktop|mobile|tablet) |
Following Operators are supported for conditional redirect:
Operator | Purpose |
Equal to (=) | Value matches exactly. |
Not equal to (!=) | Value must be excluded exactly. |
Regex matches (~) | Use RegEx to define a dynamic value which must be included. |
Negative regex matches (!~) | Use RegEx to define a dynamic value which must be excluded. |
After configuring your custom rule, review all the entered details. Once everything looks correct, click Add Rule at the top-right corner of the page to save and apply the new rule to your application.
Delete Rewrite Rules
You can delete an existing rule by clicking the three-dot menu next to it and selecting the “Delete” option.
After selecting Delete, a pop-up will appear. Click the “Delete Rule” button in the pop-up to remove the specific rule.
Edit Rewrite Rules:
To edit a rule, click the three-dot menu next to it and select Edit.
Edit the relevant configuration and click on Update Rule.
Re-Order Rewrite Rules
If multiple rules exist, you can reorder them to define the sequence in which they are executed. This ensures that higher-priority rules are applied first.
Once you have reorder your rules make sure to click on Save.
Common Examples of Rewrite Rules
Permanent Page-Specific Redirect (301): Redirect a request for a specific old page to a new, corresponding page.
Example: Move traffic permanently from https://example.co/old-page to https://example.com/new-page.
Permanent Domain-Level Redirect (301): Use this rule to permanently redirect traffic from a specific URL path on one domain to a different domain. This is commonly used when a page or section has permanently moved.
Example: Redirect traffic from /old-page/ to https://hello.com.
This ensures that any visitor accessing the old path is automatically redirected to the new destination using a 301 (permanent) redirect, which is recommended for SEO.
Geographic-Based Redirect: You can automatically redirect visitors based on their geographic location (such as country or region) to a localized version of your website.
Example: Redirect visitors coming from Europe to the /eu page. This results in URLs like:
Device-Based/Mobile Redirect: Redirect visitors using a mobile device (smartphones, tablets) to a dedicated, mobile-optimized subdomain or path.
Example: Redirect mobile users to a URL such as https://amp.domain.com.
Canonical Domain Redirect (www ↔ non-www): Use this rule to standardize your website’s primary domain by permanently redirecting one version to the other (for example, redirecting www.domain.com to domain.com, or vice versa). This helps avoid duplicate content issues and improves SEO consistency.
Example: Redirect all traffic from www.domain.com to domain.com.
Rule configuration:
Action: Permanent redirect (301 status code)
Source:
/*Destination:
https://domain.com/*Attach condition: Enabled
Condition Type: Host
Operator: Equals (=)
Value:
www.domain.com
*Attach condition allows you to apply a rule only when specific conditions are met, such as:
A specific domain or host
A visitor’s country or region
Other request-based attributes
When enabled, the redirect will trigger only if the defined condition matches, giving you more control over when and how rules apply.
This ensures all requests to the www version are permanently redirected to the non-www version.
That’s it! We hope this article was helpful.
Need Help?
If you need assistance, feel free to:
Visit the Cloudways Support Center
Chat with us: Need a Hand > Send us a Message
Or create a support ticket anytime.
We're here 24/7 to help you!

