lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: anybody know apache? (dir structure of docs)


From: Reinhold Kainhofer
Subject: Re: anybody know apache? (dir structure of docs)
Date: Thu, 12 Nov 2009 22:34:19 +0100
User-agent: KMail/1.12.3 (Linux/2.6.31-14-generic; KDE/4.3.3; i686; ; )

Am Donnerstag, 12. November 2009 21:47:45 schrieb Graham Percival:
> Anybody want to save me a half an hour of maintenance, and a few
> hours of sanity?  Look this up.
> (alternately, if you already know apache, just answer the question)
[..]
> > Can't we have the directory structure internally with /web/ ,
> > /download/ what have you, and use some serverside URL rewriting to
> > make translate
> >
> >  /foo/
> >
> > into
> >
> >  /web/foo/
> >
> > ? Does apache have mechanisms for rewriting the serving path without
> > rewriting the URL that appears in browser window?

Yes, of course. Just use the mod_rewrite module (if its not already enabled, 
run "a2enmod rewrite").

In the .htaccess file in the server's base web directory (i.e. the dir that 
contains web/), simply add:

###########################################

## Rewrite all non-existing files at toplevel to the /web/ dir, so our 
## internal structure for rsync doesn't have to be changed.
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /web/$1 [QSA,L]


###########################################

Explanation:
First, turn on the rewriting engine and tell it that it is rewriting at the 
web server root (I'm not sure whether the RewriteBase is needed at all).

Then we check, if a file (-f) or a dir (-d) with the requested name exists. Or 
rather, we check that none of them exist (the ! negation) and only in that 
case, rewrite all requests from /foo/ to use /web/foo/ internally instead.

Cheers,
Reinhold


-- 
------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]