Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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]
</ifModule>

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
add comment

1 Answer

up vote 1 down vote accepted

.htaccess rules only apply within scope. If someone makes a request to a.example.com and the .htaccess file for example.com is not inside the document tree of a.example.com, that file won't be read or respected. If the vhosts serving a.example.com and example.com 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
show 1 more comment

Your Answer

 
discard

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.