I'm using mod_rewrite to map /foo/bar/baz to /foo/qux using

RewriteEngine on
RewriteBase /foo/
RewriteRule ^bar/baz$ bar/baz/ [L,R=permanent]
RewriteRule ^bar/baz/(.*) qux/$1 [L]

I want to allow indexes in /foo/qux, so I have Options +Indexes in /foo/qux/.htaccess.

The problem is that the index output reads "Index of /foo/qux" even when the URL used to access it is /foo/bar/baz. Ideally, I'd like the output to reflect the URL used (so either /foo/qux or /foo/bar/baz, depending). I'd settle for the output always saying "Index of /foo/bar/baz". Is there a way to do this using mod_rewrite or plain-vanilla Apache configuration options?

link|improve this question
The only suggestion I can make is to use the P flag rather than L, although I can't be sure this will work and will be more complicated as it require mod_proxy installed. – David Pashley Jun 5 '09 at 14:49
Proxying doesn't make a difference. – Chris Conway Jun 5 '09 at 19:22
feedback

2 Answers

This isn't pure Apache configuration option, but as an alternative you could replace the Rewrites with symbolic links on the actual file system. With Linux, you would use:

ln -s <target> <link_name>
link|improve this answer
This doesn't work: the whole point is to map baz in the component bar to another component qux that bar doesn't necessarily know about. I don't want any information about qux leaking into the bar hierarchy. – Chris Conway Jun 5 '09 at 17:42
I'm not quite sure what exactly what you mean with this comment other than the 'its not what I want' part... (It is Friday :-) ) The only other thing I recommend is that if you are already using mod_php you can find lots of generic directory listing code that will do the same thing that the Index directive does. I would think it would be pretty easy to alter the php to display the file listing based on the URL requested. Good luck, it is an interesting problem. I wouldn't be surprised if there is a pure apache answer. – Kyle Brandt Jun 5 '09 at 18:31
Sorry, I knew I wasn't being clear... I don't want explicit links from /foo/bar to /foo/qux because /foo/bar is being copied over from another project that has no need to know about the details of the filesystem layout on the web server. I want the web server configuration to handle it, rather than pushing those dependencies into the project. – Chris Conway Jun 5 '09 at 19:11
feedback

I don't believe it's possible, due to the order in which mod_rewrite and mod_autoindex handle the request. The path that mod_autoindex receives is and must be the "real" one.

Kyle's symlink workaround is the only solution I'm aware of.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.