Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-19T17:45:52.763Z
Answers.Text: Thanks, this is exactly what I needed. Long live [F]!!
Answers.UserDisplayName: 4midori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-16T07:41:00.637Z
Answers.LastActivityDate: 2021-07-16T07:41:00.637Z
Answers.UserDisplayName: MoritzLost
Body: <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>
  
Tags: <control-panel><multi-site>
Title: Block access to /admin on secondary sites
ThreadText: # 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](https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriterule) with the [F flag](https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_f) to deny any matching request with a HTTP 403 response. Use [RewriteCond](https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#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]!!  
  
  ---
  
  