Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to enable rewriting for all websites on my server.

Instead of having to add for each website

<Directory /var/www/mywebsite1>
    AllowOverride All

<Directory /var/www/mywebsite2>
    AllowOverride All


Can I just write something like

<Directory /var/www/*>
    AllowOverride All

to specify I want rewrite enable on all subfolders ?


share|improve this question

1 Answer 1

up vote 0 down vote accepted

I believe that the following question answered here on ServerFault will answer your question:

Apache: Using same Directory directive for multiple virtual hosts

Short version is, yes, you can generally place a Directory directive outside of your VirtualHosts containers so that it will be applicable to all VirtualHosts.

share|improve this answer
ok I see, so <Directory /var/www/*> is correct ? Or I actually don't need the * in the end ? I've actually tried both but it doesn't work. I'm missing something.. I've .htaccess file in the website directory and mod_rewrite is on –  Patrick Nov 2 '10 at 22:28
You have RewriteEngine On? Crank up the RewriteLogLevel to 3 to see what is happening. –  Mark Wagner Nov 2 '10 at 23:19
If you want the <Directory> directive to match a regular expression, per, you need to use the ~ before the regex so that Apache knows how to interpret the directive (such as <Directory ~ abc$>. But by default, "Directives enclosed in a <Directory> section apply to the named filesystem directory and all subdirectories of that directory", so you should not need a regex to apply to all subdirectories of /var/www ( –  runlevelsix Nov 3 '10 at 13:36

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.