<p>If you're using Apache, you can use a <a href="https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriterule" rel="nofollow noreferrer">RewriteRule</a> with the <a href="https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_f" rel="nofollow noreferrer">F flag</a> to deny any matching request with a HTTP 403 response. Use <a href="https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewritecond" rel="nofollow noreferrer">RewriteCond</a> to apply your rule only to specific domains, or everything <em>but</em> that specific domain in your case. Something like this should work:</p>
<pre><code>RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?primaryDomain\.com$ [NC]
RewriteRule ^/?admin - [F]
</code></pre>

CC BY-SA 4.0
2021-07-19T17:45:52.763Z
Thanks, this is exactly what I needed. Long live [F]!!
4midori
CC BY-SA 4.0
2021-07-16T07:41:00.637Z
2021-07-16T07:41:00.637Z
MoritzLost
<p>I'm not clear on how to block access to the control panel at:
secondDomain.com/admin
secondDomain.com/admin/login</p>
<p>I can use .htaccess or Craft's config.php.</p>
<p>I want folks to get an ugly 'access denied' server msg when they try.</p>
<p>I only want the control panel to load at primaryDomain.com/admin.</p>

<control-panel><multi-site>
Block access to /admin on secondary sites
# Block access to /admin on secondary sites

(Asked by: username_0 on 2021-07-15)

I'm not clear on how to block access to the control panel at:
secondDomain.com/admin
secondDomain.com/admin/login

I can use .htaccess or Craft's config.php.

I want folks to get an ugly 'access denied' server msg when they try.

I only want the control panel to load at primaryDomain.com/admin.

**Tags:** control-panel, multi-site

---

## 1 answers

### Answer by username_1 on 2021-07-16. Score: 2 | Accepted answer

If you're using Apache, you can use a RewriteRule with the F flag to deny any matching request with a HTTP 403 response. Use RewriteCond to apply your rule only to specific domains, or everything but that specific domain in your case. Something like this should work:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?primaryDomain\.com$ [NC]
RewriteRule ^/?admin - [F]

> **Comments:**
> **username_0**: Thanks, this is exactly what I needed. Long live [F]!!  

---

