3

This is a follow-up question to my previous question on this site. Maybe I should point out that the Apache server is running on a windows system, don't know if it matters.

My problem is following:
I have 2 drives J: and K:, both have a directory test (J:/test/ and K:/test/)
J:/test/ contains the file pink.html
K:/test/ contains the files red.html and blue.html
I want to access all files in J:/test/ and K:/test/ with the the same url:

This is an excerpt from my httpd.conf file:

Alias /test/ "J:/test/"
Alias /test2/ "K:/test/"

<Directory "J:/test/">
Order allow,deny
Allow from all

Options All MultiViews
AllowOverride None


RewriteEngine on

RewriteCond /test/%(REQUEST_FILENAME) !-f #if we can't find the file in /test/
RewriteRule ^(.+) /test2/$1 [L]   #rewrite url into /test2/something.html

RewriteCond /test/%(REQUEST_FILENAME) -f #if we find the file in /test/
RewriteRule ^(.+) /test/$1    #should this even be necessary ?


</Directory>  

This works only partially, i can access red.html and blue.html at the K: drive but not pink.html on the J: drive. It seems to totally ignore the 2nd RewriteCond-RewriteRule pair. How do I configure httpd.conf to access pink.html?
I have tried several approaches but to no use :-( I hope my question is clear and that someone could shed some light on this matter.
Thanks in advance! /Alex

Alex F
  • 41
  • 2
  • For consistency you could try making aliases for /test1/ and /test2/ and redirecting accordingly. – Gleb Oct 02 '09 at 15:30

3 Answers3

1

Try this,

RewriteRule ^(.+) /test/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/test/(.+) /test2/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/test2/(.+) /test3/$1

...

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/test1E+10/(.+) http://www.google.com/search?q=where-is-$1 [L]
Lenik
  • 792
  • 8
  • 13
  • 27
0

Under Linux you could do this at the filesystem level as there are several filesystems that support unioning other filesystems this way (even in read+write mode) but I don't think there is a way of doing this in Windows.

Another option, again at the OS level rather than Apache, might be to bring all the files into one place as symbolic links. This is possible under Windows if you are using NTFS filesystems using utilities such this one from SysInternals.

David Spillett
  • 22,754
  • 45
  • 67
0

You shouldn't need the second RewriteCond/Rule combo, as basically you're trying to tell Apache to do the same thing it would do anyways. Basically the default action if a file is found where it was asked (/test/pink.html) is to serve it up to the client.

I would move those Rewrite* outside your Directory construct; that container is more typically used for access restrictions, what you're doing is a logical redirection. After moving the Rewrite* out and getting rid of the second stanza, edit your RewriteCond to use {} and not () characters as that is the appropriate way it's done.

If after all this it's still not working, add these two lines:

RewriteLog "c:/rwlog.txt"
RewriteLogLevel 7

...restart Apache, test and go read the log file to figure out what next Apache doesn't like.