my code


VirtualHost / Basic Auth / Alias / Log / log rotate / Rewrit
by shomwoys

Snippet options

Download: Download snippet as virtualhost-basic-auth-alias-log-log-rotate-rewrit.txt.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

NameVirtualHost *
<VirtualHost *:80>
    DocumentRoot "/path/to/document/root"
    <Directory "/path/to/document/root">
          AllowOverride All
        Options ExecCGI
        Order allow,deny
        Allow from all

    <FilesMatch "^[\._]ht">
        Order allow,deny
        Deny from all
        Satisfy All

    <Directory "/path/to/document/root/need/auth">
        AllowOverride All
        Order allow,deny
        Allow from all
        AuthType Basic
        AuthName "Enter user name and passwd"
        AuthUserFile /path/to/htpassword
        AuthGroupFile /dev/null
        Require valid-user

    # need mod_alias
    Alias /aliased "/path/to/alias"
    <Directry "/path/to/alias">
        AllowOverride All
        Order allow,deny
        Allow from all

    #need mod_rewrite
    RewriteEngine On
    RewriteRule ^source_patern$ dest_pattern [L,R]
    RewriteRule ^/favicon.ico$ /static/images/favicon.ico [L,R]
    RewriteCond %{HTTP_USER_AGENT} ^.*(Docomo|KDDI|UP.Browser|J-Phone|Vodafone|SoftBank|iPhone|iPod).*$
    RewriteRule ^/$ /mobile/ [L,R]

    # mod_python and django
    # LoadModule python_module modules/
    <Location "/app">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE application.settings
        SetEnv PYTHON_EGG_CACHE /tmp/python-egg-cache
        PythonOption django.root /app
        PythonPath "['/path/to/django/apps','/path/to/libraries'] + sys.path"

    # mod_wsgi and django
    # LoadModule wsgi_module modules/
    WSGIScriptAlias /app /path/to/wsgi/file.wsgi
    <Directory /path/to/wsgi>
        Order deny,allow
        Allow from all

    # for django admin
    Alias /media /path/to/python/site-packages/django/contrib/admin/media
    <Directory /path/to/python/site-packages/django/contrib/admin/media>
        Order allow,deny
        Allow from all

    # mod_php PHP
    # LoadModule php5_module /path/to/module
    # AddType application/x-httpd-php .php
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    PHPINIDir /path/to/phpini/parent/
    Alias /path/to/phpapp/root/
    <Directory /path/to/phpapp/root>
        Order allow,deny
        Allow from all
        Options ExecCGI

    # proxypass (for tomcat6 ajp) FIXME:
    include conf/httpd-tomcat.conf
    <Location /proxied>
        ProxyPass /proxied ajp://localhost:8009/proxied

    # for static files
    <LocationMatch "\.(jpg|gif|png)$">
        SetHandler None

    # errors
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 503 /error/503.html

    ErrorLog logs/server_name/error_log
    TransferLog logs/server_name/access_log
    CustomLog "|/usr/sbin/rotatelogs /log/to/host/access_log.%Y-%m-%d 86400 540" combined


Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.