Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a .htaccess in an addon domain, which successfully hides the wp-admin folder:

# Hide wp-admin
<ifModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_USER_AGENT} !MagicString
 RewriteRule ^wp-admin/.*$ - [R=404,L]

Now I'd like to move this to the root domain's .htaccess so it hides all the wp-admin folders on all addon domains. But try as I may, it ain't working. What am I doing wrong?

share|improve this question
up vote 1 down vote accepted

.htaccess rules only apply within scope. If someone makes a request to and the .htaccess file for is not inside the document tree of, that file won't be read or respected. If the vhosts serving and aren't the same, you'll need to apply that rule to each vhost separately.

You may be able to apply rewrite rules across multiple subdomains if they use the same vhost (put the rule in the vhost definition block, which is more efficient than using .htaccess).

share|improve this answer
Thank you, this makes sense, because I can't even cause it to 404 with RewriteRule .* - [R=404,L] which indicates we're not even touching it. – harvest316 Apr 23 '12 at 13:28
But editing the <VirtualHosts> section is gonna be a problem coz I'm on shared hosting. Any workarounds for this situation? – harvest316 Apr 23 '12 at 13:29
You're going to need to drop that .htaccess in the root of each subdomain, then, and treat the root domain like a subdomain with no name. – pjmorse Apr 23 '12 at 13:32
Although I'm pretty sure the wordpress installs on each addon domain will need their .htaccess files, I dropped one .htaccess from the root of an addon domain, with no effect. Not sure what you mean about treating the root domain like a subdomain with no name? – harvest316 Apr 23 '12 at 13:47
I mean that as far as Apache is concerned, each one is a vhost; it doesn't care if it's the primary domain or a subdomain. You may need to check that each host is actually reading and respecting configuration directives found in .htaccess files. – pjmorse Apr 23 '12 at 15:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.