I'm looking to do this
<VirtualHost *>
ServerName myDomain.com
DocumentRoot /var/www/myDomain
<Directory /var/www/myDomain>
Rewrite on
RewriteRule ^blog/(.*)$ /var/www/myBlog/$1 [L]
</Directory>
</VirtualHost>
So http://www.myDomain.com/blog/ will read files from a different directory. The above will not work so, how can I do this without moving the files?
There's no need to user mod_rewrite for this. Alias is better suited.
If you want to change settings for just your blog, add a location directive.
Do it like this:
Location
tags are just a generic container for Apache directives so use it to 'wrap' whatever you want to apply to that 'external view' section of the website. Very useful if you're pulling content from multiple physical directories into one larger structure, you can apply the same set of rules to all of them, instead of having multipleDirectory
entriesAlias
directive is a simple redirect, great for long paths showing up as short and neat pointers.DocumentRoot
directive sets the top web content directory.All of them deal with directories, but they're all a bit different. Location is mostly for dealing with what I'd call the 'web view'--how it's visible from the outside. Directory is for the 'physical view' of dealing with actual directories on the filesystem. If contents of one directory get served out as one URL, then there isn't a functional difference between them.
However, once you start 'composing' multiple directories, serving them out of multiple URL's that don't necessairly mirror their filesystem hierarchy, you need to mix and match all these directives for the desired effect. Just because two directives might behave the same in one situation, doesn't mean they're going to behave the same way in another.