Re: How to access http://localhost/doc for FHS compliant packages
Andreas Tille <tillea@rki.de> writes:
>> /etc/apache/srm.conf says:
>>
>> Alias /doc/ /usr/doc/
>> ## The above line is for Debian webstandard 3.0, which specifies that /doc
>> ## refers to /usr/doc. Some packages may not work otherwise. -- apacheconfig
>>
>> OK, so far but now there are some packages which reside in /usr/doc
>> and some in /usr/share/doc which both want to be accessed via
>> http://localhost/doc. What is the recommended way while we are in
>> the process od switching to FHS.
ccwf@bacchus.com (Charles C. Fu) writes:
> Since this has come up a few times, here's a fairly complete solution:
I did a little more research, and my Apache solution needs a couple of
patches.
> In httpd.conf, enable mod_rewrite
>
> LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so
>
> if not already enabled.
Note: rewrite_module is currently enabled by default.
> In srm.conf, replace
>
> Alias /doc/ /usr/doc/
>
> with
>
> <IfModule mod_rewrite.c>
> RewriteEngine on
>
> # For requested files beginning with /doc/, try looking for the
> # document in /usr/share/doc.
> RewriteCond %{REQUEST_FILENAME} ^/doc/
> RewriteCond /usr/share%{REQUEST_FILENAME} -f
Replace the last line above with
RewriteCond /usr/share%{REQUEST_FILENAME} -f [OR]
RewriteCond /usr/share%{REQUEST_FILENAME} -d [OR]
RewriteCond /usr/share%{REQUEST_FILENAME} -l
in order to handle directories and symlinks.
> RewriteRule ^(.+) /usr/share$1 [L]
>
> # Next, try looking for the document in /usr/doc.
> RewriteCond %{REQUEST_FILENAME} ^/doc/
> RewriteCond /usr%{REQUEST_FILENAME} -f
Again, change the last line to
RewriteCond /usr%{REQUEST_FILENAME} -f [OR]
RewriteCond /usr%{REQUEST_FILENAME} -d [OR]
RewriteCond /usr%{REQUEST_FILENAME} -l
> RewriteRule ^(.+) /usr$1 [L]
>
> # Attempt to deal with directory listings.
> RewriteCond %{REQUEST_FILENAME} ^/doc/?$
> # Just list /usr/share/doc for now.
> RewriteRule ^(.+) /usr/share/doc/ [L]
>
> # Neither worked. Just pass through to do whatever we would have
> # done before.
> RewriteRule ^(.+) - [PT]
> </IfModule>
>
> <IfModule !mod_rewrite.c>
> # mod_rewrite isn't available, so fallback to a simple Alias.
> Alias /doc/ /usr/share/doc/
> </IfModule>
>
> These rules will look for http://localhost/doc/foo in both
> /usr/share/doc/foo and /usr/doc/foo ....
Enjoy, :-)
-ccwf
Reply to: