views:

76

answers:

2

What I'm trying to accomplish is pulling content from a directory that is not the same as the url path. For example:

  • URL: example.com/
  • path: /www/production/

Currently, the root url pulls content from the path above. What I want to do is something like this:

  • URL: example.com/
  • path: /www/production/root/

So the base URL "example.com" should pull data not from /www/production/ but from /www/production/root/.

I think this is called a Virtual Directory in IIS. Is there something like this in Apache?

Edit for clarification:

I have a ton of existing content that I do not want to have to restructure yet. However, the root site is being completely rebuilt and is going to be quite a bit bigger. What I want is each microsite to have it's own directory, such that requests for example.com/ should pull content from /www/production/root/ while requests for example.com/microsite/ should still pull content from /www/production/microsite/.

Hopefully that makes more sense. :)

A: 

If I understand your question correctly, then the following, in your VirtualHost config, does what you're asking for:

ServerName example.com
DocumentRoot /www/production/root/
RTBarnard
Well, this won't actually work because there are other micro-sites that need to continue to be referenced by matching the url to the directory structure. so example.com/sales/jobs/ pulls from /www/production/sales/jobs/. What I'm trying to do is keep the rest of the server structure intact while not having to spill 60+ files into the root of the directory structure for the root site. Make sense?
Cypher
+1  A: 

Its not exactly clear what your problem is. If you just want all URLs to be taken relative to some location on the server, then you can use the DocumentRoot directive:

DocumentRoot /www/production/root/

If you want to only have certain urls go to the new place, then you can either use the Alias or AliasMatch directives from the mod_alias module. These can map either prefixes on a URL, or url Regexes to other server locations. If even this isn't sufficient, you can use mod_rewrite which allows for arbitrary chains of url rewriting, but can get very hairy to maintain, so you're better off avoiding that module if you can.

http://httpd.apache.org/docs/2.0/mod/mod_alias.html

swestrup
Sorry if my post was a bit unclear. Maybe my recent edit will help clarify the situation... although it sounds like mod_alias might be the way to go here... I'll have to peek at some documentation.
Cypher
Thanks, this is exactly what I needed.
Cypher