Skip to content

Web Rules, htaccess and robots.txt on Cloudways: 2026 Guide

On this page

Last updated: · By

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-wwwWeb Rules
Add security headers (HSTS, X-Frame-Options)Web Rules (Header Rules)
Block a specific IP address or bothtaccess (Hybrid), or the server firewall
Password-protect a site under developmenthtaccess, or temporarily blocking access to the application
Stop Google from crawling a folderrobots.txt
Remove a page from search resultsA 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

  1. In the panel’s side menu click My Applications.
  2. Pick the application.
  3. In the application’s menu click Web Rules.
  4. Choose a tab: Header Rules (headers) or Rewrite Rules (redirects and rewrites). Header Rules opens by default.
The Web Rules screen for header and redirect rules
The application’s Web Rules screen, with the Header Rules and Rewrite Rules tabs

The limits, and when to stay with htaccess

Rule typeMaximum per applicationConditions
Header Rules10–
Redirect / Rewrite Rules25One 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)

  1. In the Rewrite Rules tab click Add Rewrite Rule.
  2. 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.
  3. 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.
  4. Under Source enter the address or pattern that triggers the rule, for example /old-page.
  5. Under Destination enter the target: a path like /new-page or a full URL.
  6. 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

  1. Add Rewrite Rule.
  2. Action: Permanent Redirect (301).
  3. Source: /*
  4. Destination: https://domain.com/
  5. Attach Condition: type Host, operator Equal to (=), value www.domain.com.
  6. 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

  1. In the Header Rules tab click Add Header Rule.
  2. Under Rule Type choose Custom, or one of the ready-made templates.
  3. Under Action choose Set (add or change) or Unset (remove).
  4. Enter the Header Name and Value.
  5. Leave Always Apply on so the header applies to all requests, or turn it off and attach a condition for a specific URL.
  6. Click Add Rule.
GoalHeader NameValue
Force HTTPS for two years (HSTS)Strict-Transport-Securitymax-age=63072000; includeSubDomains; preload
Prevent caching of a file that must always be freshCache-Controlno-store, no-cache, must-revalidate, max-age=0
Block your site from being embedded in an iframe on other sitesX-Frame-OptionsSAMEORIGIN
Hide the server typeServer (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

  1. On your computer, create a text file named robots.txt (lowercase), encoded as UTF-8.
  2. Write the rules (an example follows).
  3. Upload it to the application’s public_html folder, through the file manager or SFTP with FileZilla.
  4. 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
RuleMeaning
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: /pathAn 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:

  1. In the application’s public_html folder run pwd and copy the full path.
  2. Create a password file and a user (the system asks for the password twice): htpasswd -c .htpasswd USERNAME
  3. 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.

General application settings: Webroot, reset permissions and cache clearing
Application settings: the application folder, Webroot, reset permissions and Varnish

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.

  1. In Application Settings find the Webroot field.
  2. Enter the new path. It must be inside public_html, for example public_html/public.
  3. 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.

  1. In Application Settings scroll to CORS Header.
  2. 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:

  1. In Application Settings scroll to Application Access.
  2. 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.

  1. Over SSH run hostname and note the result.
  2. 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
  1. 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
  1. 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.

Black Friday80% off
80% off 2 months of managed hosting

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).

Ends in—days—hours—minutes—seconds
Code:
Grab the 80% now

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

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

Frequently asked questions

Where is the robots.txt file on Cloudways?

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.

Why isn’t my htaccess file working on Cloudways?

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.

How many redirects can I set up in Web Rules?

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.

Do Web Rules also work on the Hybrid Stack?

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.

Does robots.txt protect sensitive folders?

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.

How do I hide a site under development from Google and visitors?

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.

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

Picture of Asael Dreyer
Asael Dreyer

Hi, I'm Asael Dreyer, CEO of an SEO agency that runs hundreds of websites hosted on dozens of Cloudways servers.
Everything you will find here comes from hands-on experience, mine and my teams', straight from the field: from the guides to the recommendations. All to help you get the most out of Cloudways.

More about me →

Need help? Got a question about your server or this guide? Write to us and we will get back to you.

More guides on this topic:
מפריד
Thanks for your message!
We will get back to you soon.
Ready to get started?

Sign up with the coupon code ASAEL