Forum Moderators: phranque

Message Too Old, No Replies

Merge access to files from two or more directories?

         

JAB Creations

5:48 pm on Feb 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The Goal

I need to merge access to XML files accessible from the root XML directory while still being able to access the domain user's XML files using the same client path.

The Setup

public_html/ (Not accessible on any domain)
public_html/.htaccess
public_html/www.example1.com/
public_html/www.example1.com/xml/ (domain XML/user XML)
public_html/www.example2.com/
public_html/www.example2.com/xml/ (domain XML/user XML)
public_html/www.example3.com/
public_html/www.example3.com/xml/ (domain XML/user XML)
public_html/xml/ (root XML/system XML)

So if a person requests...
http://www.example1.com/xml/example.xml

...Apache first looks for...
public_html/www.example1.com/xml/example.xml

...and if it can not find a file with the domain's user XML directory it then looks for...
public_html/xml/example.xml

...with the rule applying to any XML files in the XML directory.

I can rewrite files from the user XML directory to the system XML directory using this rule...
RewriteRule ^[^/]*/xml(.+) xml$1

...however that does not merge files from both the user and system XML directories. If we saw an Apache directory listing I need to see all the XML files listed from both the user and system XML directories. I'll reiterate that if there are files that share the same names that the user XML file should override the system file.

Keep in mind that I need to use the .htaccess file I've specified above to make sure this works for all domains. I've been trying to figure this out for two weeks without success, not sure what Apache uses in place of the word merge. Also my highest priority is getting something to work and then refining the code. Thoughts please?

- John

lucy24

8:43 pm on Feb 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Preliminary question: Does it matter what the user sees? That is, if they ask for example1.com/blahblah is it essential for them to continue seeing example1.com, or is it OK if they see example.com instead?

I ask this because a redirect (using mod_rewrite of course) may be simpler and safer than a rewrite. Let us not even talk about proxies. Yet.

There is also the dreaded

!-f

as included in every boilerplate htaccess ever published. Rarely necessary or desirable, but you may need to fall back on it here.