Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>Directory</code> is a directive targeting a file system directory, and should always have a path (waildcards allowed).</p> <p>Using some instructions targetd to no directory may be discarded silently, or maybe with an error (you could test it), but is would certainly be <strong>useless</strong>.</p> <p><strong>Why would you write some configuration instructions targeted to no directory at all</strong>?</p> <p>But there's maybe more things in your question.</p> <p>Ususally a Virtualhost should contains at least one Directory instruction, the DocumentRoot directory, and usually we also add one targeting the root of the filesystem, this way:</p> <pre><code>&lt;Directory /&gt; (instructions to deny access and avoid .htaccess reads) &lt;/Directory&gt; &lt;Directory /my/document/root/&gt; (instructions to allow access and still avoid .htaccess reads or to allow them if you are lazy and feel over confident that .htaccess are useful in any way and you do not need speed) &lt;/Directory&gt; </code></pre> <p>And you could add more, especially to avoid usage of <code>.htaccess</code> files as such file stored in <code>/path/to/somewhere</code> is the same thing as a <code>&lt;Directory /path/to/somewhere&gt;</code> section, but slower.</p> <p>Now you do not like to repeat yourself in your VH configuration, so you coud maybe use .htaccess files or global level instructions for things that are usually set there. And you could also use another magical keyword, which is <strong>Location</strong>.</p> <p>You can use a lot of Apache instruction in a <code>&lt;Location /foo&gt;</code> directive. Locations works on url, not on filesystem paths.</p> <p>So <code>&lt;Location /&gt;</code> is your documentRoot, and <code>&lt;Location /foo&gt;</code> is maybe the subdirectory 'foo' under you DocumentRoot. This could help you write things in your VH without reusing the documentroot prefix everywhere. But <strong>be careful</strong>, urls are not file-system paths. Any protection applied on the url level may be weaker or stronger compared to a protection applied on a directory level. It depends on your alias, the way you use urls, etc.</p> <p><strong>Update</strong>:</p> <p>If you use the new Apache <strong>2.4</strong> version you can now use <a href="http://httpd.apache.org/docs/current/mod/mod_macro.html" rel="nofollow">mod_macro</a> or even easier, <a href="http://httpd.apache.org/docs/current/en/mod/core.html#define" rel="nofollow">built-in variables support</a>:</p> <pre><code>Define docroot "/path/to/mysite" DocumentRoot ${docroot} &lt;Directory ${docroot}&gt; (...) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload