nixCraft Poll

Topics

Configure lighttpd alias (mod_alias)

Posted by Vivek Gite [Last updated: March 8, 2008]

This lighttpd module provides for mapping different parts of the host filesystem in the document tree. You can use it for mapping various directories. For example cgi-bin directory mapped to /var/lib/cgi-bin. The alias module is used to specify a special document-root for a given url-subset.

Configuration

Open your lighttpd configuration file:
vi /etc/lighttpd/lighttpd.conf

Append/add mod_ alias to list of server modules:
server.modules += ( "mod_alias" )

Examples

Add cgi-bin alias for doamin theos.in
alias.url = ( "/cgi-bin/" => "/home/lighttpd/theos.in/cgi-bin/" )

Browse all documents installed at /usr/share/doc/ directory with following alias:
alias.url = ( "/docs/" => "/usr/share/doc/" )
alias.url += ( "/stats/" => "/home/theos.in/http/webalizer/" )

Open a browser and type url http://theos.in/docs/ or http://your-domain.com/docs/

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Dunxd Says:

    Want to add more than one alias?

    Use += for subsequent alias.url lines.

    E.g.

    alias.url = ( "/cgi-bin/" => "/home/lighttpd/theos.in/cgi-bin/" )
    alias.url += ( "docs/" => "/usr/share/doc/" )

  2. Dunxd Says:

    On Windows the trailing slash for the alias (the first path) breaks the configuration.

    E.g.

    alias.url = ( "/docs/" => "/usr/share/doc/" )
    ^

    Doesn’t work.

    alias.url = ( "/docs" => "/usr/share/doc/" )

    Does work.

  3. nixcraft Says:

    Dunxd,

    Thanks for pointing out windows and UNIX difference while configuring alias.

    Appreciate your post.

  4. nixcraft Says:

    You can use += or use following syntax:
    alias.url = (
    "/stats/star/" => "/home/lighttpd/stats/out/",
    "/docs/" => "/usr/share/docs/",
    "/somedir/" => "/home/somewhere/"
    )

  5. Minh Says:

    In this line:

    server.modules += ( “mod_ alias” )

    Is the space bewteen “mod_” and “alias” intentional?

  6. vivek Says:

    > Is the space bewteen “mod_” and “alias” intentional?
    Noop, it was a typo.

  7. Howard Miller Says:

    It appears that when using an alias, the index.file-names setting is ignored. If, for example, you want index.php to be found then it won’t work with an alias.

    Is this a bug, or am I missing something obvious?

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.