0

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>

<Directory /var/www/mywebsite2>
    AllowOverride All
</Directory>

...

Can I just write something like

<Directory /var/www/*>
    AllowOverride All
</Directory>

to specify I want rewrite enable on all subfolders ?

thanks

1 Answer 1

0

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.

3
  • 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
    – aneuryzm
    Nov 2, 2010 at 22:28
  • You have RewriteEngine On? Crank up the RewriteLogLevel to 3 to see what is happening. Nov 2, 2010 at 23:19
  • If you want the <Directory> directive to match a regular expression, per httpd.apache.org/docs/2.0/mod/core.html#directory, 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 (httpd.apache.org/docs/2.0/sections.html#file-and-web). Nov 3, 2010 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .