Last updated: · By Asael Dreyer
Short answer: Cloudways gives you two ways to control how the server responds to requests: Web Rules (in public beta, Public Preview, as of November 2026), a panel interface that adds 301/302 redirects, internal rewrites and HTTP headers without touching any files, and the classic .htaccess file, which only works on the Hybrid Stack. The robots.txt file is a plain text file you upload to your site’s public_html folder over SFTP or in the file manager, or manage from inside WordPress. In the same application settings area you can also change the Web Root, enable CORS and temporarily block access to the site.
⏱ Time: 5–15 minutes · Difficulty: easy (Web Rules, robots.txt) to medium (htaccess) · Last checked against the official documentation: 6 Nov 2026
What is the difference between Web Rules, htaccess and robots.txt?
These tools sound similar, but they do completely different things. It’s worth understanding the difference before you start.
Web Rules are rules the server applies to every request that reaches your site. For example: “send anyone who visits www to the address without www”, or “add a security header to every response”. Cloudways built this interface together with the Lightning Stack, which has no Apache and therefore no htaccess, but it also works on the Hybrid Stack.
Note: Web Rules is in public beta (Public Preview). The panel shows a Public Preview badge next to the title. According to Cloudways documentation (updated 5 Nov 2026), Public Preview releases are early releases for wider testing: the SLA may be measured but isn’t backed by service credits, and the feature is subject to the normal retirement process. So test every rule right after you add it, and keep a copy of the important ones.
.htaccess is an Apache configuration file that sits in the site folder. It can do almost anything: redirects, IP blocks, password protection, bot blocking. It is only read when the application runs on the Hybrid Stack (Nginx and Apache). Note that on the current server setup screen Lightning is marked Recommended and is preselected for a new WordPress application, so a new application may not have an htaccess file at all.
robots.txt isn’t a server rule at all. It’s a polite request to search engines about which parts of the site to crawl and which not to. Well-behaved bots like Googlebot respect it, malicious bots ignore it. That makes robots.txt an SEO tool, not a security tool.
| You want to… | The right tool |
|---|---|
| Redirect an old page to a new one (301) | Web Rules, or htaccess on Hybrid |
| Unify www and non-www | Web Rules |
| Add security headers (HSTS, X-Frame-Options) | Web Rules (Header Rules) |
| Block a specific IP address or bot | htaccess (Hybrid), or the server firewall |
| Password-protect a site under development | htaccess, or temporarily blocking access to the application |
| Stop Google from crawling a folder | robots.txt |
| Remove a page from search results | A noindex tag (not robots.txt) |
Before you start
- Check which Stack the application runs on: Application Settings and then the WebStack tab (called the Stack setting in the documentation). The full explanation is in the guide to server settings.
- To edit htaccess and robots.txt you need file access: the file manager, SFTP or SSH.
- Before changing redirects on a live site, save a copy of the existing htaccess. A wrong redirect can take the site down or create a redirect loop.
Web Rules (beta): redirects, rewrites and headers without files
- In the panel’s side menu click My Applications.
- Pick the application.
- In the application’s menu click Web Rules.
- Choose a tab: Header Rules (headers) or Rewrite Rules (redirects and rewrites). Header Rules opens by default.

The limits, and when to stay with htaccess
| Rule type | Maximum per application | Conditions |
|---|---|---|
| Header Rules | 10 | – |
| Redirect / Rewrite Rules | 25 | One condition per rule |
Cloudways’ recommendation: up to 25 redirects and up to 10 headers, Lightning Stack with Web Rules. Beyond that, or when you need rules with several conditions, Hybrid Stack with htaccess. A site that has changed its URL structure and has hundreds of old redirects should stay on Hybrid, or move the redirects to a WordPress redirect plugin.
Creating a redirect (301, 302 or Rewrite)
- In the Rewrite Rules tab click Add Rewrite Rule.
- Under Action choose: Permanent Redirect (301) for a permanent change, Temporary Redirect (302) for a temporary one, or Rewrite for an internal rewrite where the address in the browser doesn’t change.
- Decide whether to keep the original Query String (for example
?utm_source=facebook). For campaigns it’s almost always worth keeping, so you don’t lose attribution data. - Under Source enter the address or pattern that triggers the rule, for example
/old-page. - Under Destination enter the target: a path like
/new-pageor a full URL. - If needed, add a condition (Attach Condition), then click Add Rule in the top corner.
A 301 tells Google the page has moved permanently, and its search value passes to the target. A 302 says it’s temporary, and Google keeps indexing the original address. If you aren’t sure, and for any site restructure, use 301.
Conditions: by domain, country or device
You can attach one condition to each rule. The supported condition types are: URI (path), QUERY_ARG (a parameter in the URL, without the question mark), HOST (the domain), COUNTRY CODE (a country code from MaxMind GeoIP, for example DE) and DEVICE CODE (desktop, mobile or tablet). The operators are: equal (=), not equal (!=), Regex match (~) and Regex non-match (!~).
An example: a bilingual site can send visitors from outside its home country to the English version with the condition COUNTRY CODE != DE and a 302 action. Keep two things in mind: Google crawls mostly from IP addresses in the US, so a redirect like this can stop it from seeing the local-language version. And if you do redirect by country, use a 302, not a 301.
Example: unifying www to the non-www address
- Add Rewrite Rule.
- Action: Permanent Redirect (301).
- Source:
/* - Destination:
https://domain.com/ - Attach Condition: type Host, operator Equal to (=), value
www.domain.com. - Add Rule, then test in a private browsing window.
If you have several rules, you can drag them to change their order. A rule higher up is applied first. After changing the order, click Save.
Header Rules: security and cache headers
- In the Header Rules tab click Add Header Rule.
- Under Rule Type choose Custom, or one of the ready-made templates.
- Under Action choose Set (add or change) or Unset (remove).
- Enter the Header Name and Value.
- Leave Always Apply on so the header applies to all requests, or turn it off and attach a condition for a specific URL.
- Click Add Rule.
| Goal | Header Name | Value |
|---|---|---|
| Force HTTPS for two years (HSTS) | Strict-Transport-Security | max-age=63072000; includeSubDomains; preload |
| Prevent caching of a file that must always be fresh | Cache-Control | no-store, no-cache, must-revalidate, max-age=0 |
| Block your site from being embedded in an iframe on other sites | X-Frame-Options | SAMEORIGIN |
| Hide the server type | Server (with the Unset action) | – |
The values in the table are the examples from Cloudways’ documentation. A word on HSTS with preload: it’s a long-term commitment that the site and all its subdomains will only work over HTTPS, and it’s hard to undo. Turn it on only after you have confirmed that every subdomain has a valid SSL certificate. To begin with, you can settle for a cautious value, for example max-age=300 without includeSubDomains and without preload, and only raise it once everything works.
To check that a header took effect, open the site in a private browsing window, open the developer tools (F12), click the first request in the Network tab, and look at the Response Headers. If a caching plugin or a CDN sets the same header, clear their cache and check again.
How to set up robots.txt on Cloudways
robots.txt lives in the site’s root folder, so it is reachable at https://domain.com/robots.txt. On Cloudways that’s the application’s public_html folder.
On a WordPress site: before you create a file
WordPress generates its own virtual robots.txt when there is no real file. SEO plugins like Yoast and Rank Math let you edit it from the dashboard, which is the convenient route for most sites (some plugins actually write a real file, so check what exists in the folder). If you upload a real robots.txt file to public_html, it overrides the virtual one, and changes in the plugin stop having any effect. This is a common source of confusion.
Creating and uploading the file
- On your computer, create a text file named
robots.txt(lowercase), encoded as UTF-8. - Write the rules (an example follows).
- Upload it to the application’s
public_htmlfolder, through the file manager or SFTP with FileZilla. - Open domain.com/robots.txt in your browser and make sure you see the new content. If not, clear the Varnish cache.
If you work over SSH, you can create the file directly on the server:
cd applications/APP_FOLDER/public_html
nano robots.txt
An example for a typical WordPress or WooCommerce site:
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /cart/
Disallow: /checkout/
Sitemap: https://domain.com/sitemap_index.xml
| Rule | Meaning |
|---|---|
| User-agent: * | The following rules apply to all bots |
| Disallow: / | Don’t crawl anything on the site. Fine for staging, dangerous on a live site |
| Disallow: /folder/ | Don’t crawl this folder |
| Disallow: /*.pdf$ | Don’t crawl files of a certain type |
| Allow: /path | An exception to a broader Disallow rule |
| Sitemap: | The full URL of the sitemap |
An expensive mistake: you leave Disallow: / from staging, push it to the live site, and one day discover that Google has stopped crawling your site. After every push from staging or site migration, open the live site’s robots.txt and check it. And remember: Disallow doesn’t remove a page that is already indexed. For that you need noindex, and the page has to stay open to crawling so Google can see the tag.
What you can do with htaccess on Cloudways
The .htaccess file lives in the application’s public_html, and is only read on the Hybrid Stack. The safest way to edit it is SSH or SFTP, with a backup copy before every change. On WordPress it already contains a # BEGIN WordPress block. Add your rules above it, not inside it, because WordPress rewrites that block.
Redirects and HTTPS
A permanent redirect of the whole site to a new domain:
Redirect 301 / https://new-domain.com/
Forcing HTTPS. Note that you check X-Forwarded-Proto and not the regular HTTPS variable, because on Cloudways Nginx terminates the encrypted connection and passes it on to Apache:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Unifying to www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
If you’d rather not touch code, there is also a guide to redirecting HTTP to HTTPS on Cloudways.
Password protection, IP blocking and bot blocking
Password-protecting a site under development, in three steps over SSH:
- In the application’s public_html folder run
pwdand copy the full path. - Create a password file and a user (the system asks for the password twice):
htpasswd -c .htpasswd USERNAME - Add the following lines to htaccess, using the path you copied:
AuthName "Restricted"
AuthType Basic
AuthUserFile /FULL/PATH/public_html/.htpasswd
Require user USERNAME
Blocking specific IP addresses (the addresses in the example are a documentation range only, replace them with the addresses you want to block):
<Limit GET POST>
order allow,deny
deny from 203.0.113.10
deny from 203.0.113.11
allow from all
</Limit>
Blocking a bot by User-Agent:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(BadBot|EvilScraper).*$ [NC]
RewriteRule .* - [F,L]
For blocking IPs across the whole server, and for broad protection from bots, you’re better off using the server firewall and the Bot Protection layer of Cloudflare Enterprise, both explained in the server security guide. A rule in htaccess covers only one application, and only after the request has already reached Apache. Because the request goes through Nginx first, if an IP block has no effect, the IP Apache sees may not be the visitor’s. In that case block it in the server firewall.
PHP settings in htaccess: not on new servers
Lines like php_value post_max_size 20M are common in older tutorials. On servers launched from 23 August 2016 onward, with PHP-FPM, they don’t work. You change these values in the PHP settings of the server or the application.
More settings in the same area: Web Root, CORS, blocking access and Session Path
All of these settings are in the application, under Application Settings.

Changing the Web Root
The Web Root is the folder the server serves your site from. The default is public_html. Frameworks like Laravel and Symfony serve from a subfolder (for example public), and then you need to change it.
- In Application Settings find the Webroot field.
- Enter the new path. It must be inside public_html, for example
public_html/public. - Save. If the folder doesn’t exist, it is created automatically.
Make sure the new folder contains an index.php or index.html file. Otherwise the site will show an error.
Enabling CORS
CORS lets another site load resources from your site, for example fonts, images or API calls from a separate front-end application. By default browsers block this.
- In Application Settings scroll to CORS Header.
- Turn the switch on and confirm with Confirm.
Limitations according to the documentation: the setting applies to all of the application’s domains, it overrides CORS headers set in htaccess or in code, and as of 2026 only the wildcard value (*) is supported, meaning every domain is allowed. If you need to allow a single domain only, set the header in Header Rules or in code, and leave the switch off. On CloudwaysCDN, CORS headers are already on by default.
Temporarily blocking access to the site
When a site is under development, not in use, or after a hack, you can take it offline without deleting it:
- In Application Settings scroll to Application Access.
- Turn the switch off and click Proceed.
What happens: the site doesn’t open, neither on the domain nor on the temporary URL. SFTP/SSH access with the application’s credentials is disabled (the Master user can still log in), and Cron jobs stop. Backups and the database keep working. You restore access with the same switch. Turning access off doesn’t delete anything and doesn’t stop the server itself, so don’t assume billing stops.
Setting the Session Path
This mostly matters for custom PHP applications that need a dedicated folder for Session files. On a regular WordPress site you almost never need to touch it.
- Over SSH run
hostnameand note the result. - Create a folder. The documentation recommends
public_html/var/sessions, because that folder is automatically excluded from cloning and staging creation:
cd applications/APP_FOLDER/public_html
mkdir -p var/sessions
- In the application, under Application Settings, open PHP FPM Settings and add at the end (without a semicolon at the start of the line, otherwise it becomes a comment):
php_admin_value[session.save_path] = /home/HOSTNAME/APP_FOLDER/public_html/var/sessions
- Click Save Changes.
Make sure the folder isn’t reachable from the browser, for example with an htaccess rule that blocks it, since it sits inside public_html.
The code BFCM802 takes 80% off your bill for the first two months (up to $200 off per month), including unlimited free site migrations. New customers only, and only until the offer ends.
The offer ends on December 4, 2026 at 23:59 (UTC+2).
Start with a free trial, no credit card. Enter the code at checkout and check that it shows up.
After Black Friday: 30% off for 3 months with the code ASAEL. On a large server (above about $444 a month) ASAEL already saves more today. BFCM802 vs. ASAEL calculator
Start a free trial server, no credit card. When you move to a paid plan, the code ASAEL takes 30% off your bill for the first three months.
The link fills in the code on the signup form. Just make sure it shows up.
What are the common mistakes and how do you fix them?
htaccess rules don’t work at all: the application is probably on the Lightning Stack, which has no Apache. Check the WebStack tab. Move the rules to Web Rules or go back to Hybrid.
“Too many redirects” after adding a redirect: two rules are redirecting to each other, for example a Web Rule to www and an htaccess rule to non-www, or the WordPress site address setting conflicts with the redirect. Keep just one rule, and make sure the WordPress site address matches it.
Error 500 after editing htaccess: a syntax error. Restore the copy you saved and check the new line. Smart quotes copied from a text editor are a common suspect.
You changed robots.txt and the browser still shows the old one: Varnish or a CDN is holding a copy. Clear the cache. On WordPress, also check that no plugin is generating a virtual robots.txt in parallel.
You hit the 25-rule limit: merge rules using Regex, move old redirects to a redirect plugin, or switch to the Hybrid Stack with htaccess.
The site doesn’t load after changing the Web Root: there is no index file in the new folder, or the path isn’t inside public_html.
Sources
- Cloudways Knowledge Base: How to create and manage web rules in Cloudways
- Cloudways Knowledge Base: How to setup robots.txt for your website
- Cloudways Knowledge Base: What can I do with an .htaccess file
- Cloudways Knowledge Base: How to change the web root of an application
- Cloudways Knowledge Base: How to enable CORS headers for your application
- Cloudways Knowledge Base: How to stop access to your application on Cloudways
- Cloudways Knowledge Base: Setting up the session path from the Cloudways platform
Frequently asked questions
In the application’s public_html folder, if you created one. If there is no file, WordPress generates a virtual robots.txt, and SEO plugins like Yoast let you edit it from the dashboard. A real file in the folder overrides the virtual one.
The usual reason is the Lightning Stack, which has no Apache, so htaccess isn’t read at all. Check the Stack in the WebStack tab of the application settings. A second reason: PHP settings like php_value, which don’t work on servers with PHP-FPM.
Up to 25 redirect and rewrite rules per application, with one condition per rule, and up to 10 header rules. Beyond that Cloudways recommends the Hybrid Stack with htaccess.
Yes. They were built for the Lightning Stack, but they are available on both Stacks. As of November 2026 the feature is still in public beta (Public Preview), so test every rule right after you add it.
No. robots.txt only asks search engines not to crawl, and malicious bots ignore it. What’s more, it publishes the list of folders you asked to hide. For real protection use a password, an IP block or blocking access to the application.
The simplest way is to turn off Application Access until launch. If a client needs to see the site, password protection in htaccess is better than robots.txt, because it actually blocks access.
Related guides
- Server settings and services on Cloudways
- WP-CLI on Cloudways
- How to access the file manager
- How to reset your password on Cloudways
- How to change the PHP version
- All guides on this topic: Server settings and developer tools
- Why a managed server: Cloudways hosting review
Official source: How to Create and Manage Web Rules in Cloudways, How to Setup robots.txt for Your Website, What Can I Do With an .htaccess File?, How to Change the Web Root, How to Enable CORS Headers, How to Stop Access to Your Application, Setting up the Session Path (Cloudways Knowledge Base). Written and checked by Asael Dreyer · Updated: 6 Nov 2026
Disclosure: this is an independent site, not the official Cloudways site. Some links on this site are affiliate links: if you sign up through them we earn a commission, at no extra cost to you. Full details