Htaccess in Multi-Domain System


Do any of you know how to use separate .htacces on a multi-domain system?

Step to reproduce

I work with MODx Revo 2.8.3 and XRouting. I have only one system with several contexts and each context has its own domain.

Observed behavior

So far, when I set entries like https redirection, password protection, cache settings 301 redirections and so on, it affects all domains. But of course this is not wanted.

Expected behavior

I would like to have a separate .htaccess for each context.


MODx Revolution 2.8.3, MySQL, PHP 7.3.

Does anyone have any ideas?

Do you have access to the server configuration? If that’s the case, then maybe you can define a different value for AccessFileName for each virtual host.

    AccessFileName .htaccess2

With just a single .htaccess file, you could add an additional RewriteCond to every rule to restrict it to a certain domain.

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]

Or maybe use an <If> block to structure the file.

<If "%{HTTP_HOST} == ''">

Although when I tested it, the RewriteRule in a <If> block didn’t work the same as outside the block, so this is probably not a practical solution.

maybe you could have separate directories for each domain, each with its own .htaccess and index.php all running the same MODX installation

Unfortunately, I do not have access to the server. This is located at Thanks for the tip with RewriteCond.

@bruno17 Can you tell me how to set something like this in config?