# OntoWiki .htaccess file

# WARNING: If you do not use the htaccess at all or your htaccess is
# ignored, then your config.ini can be loaded over the web !!!
<Files "*.ini">
    Deny from all
</Files>

# OntoWiki does not requires Apache's rewrite engine to work. However,
# if you would like to have nice (Linked Data) URIs you must enable URL
# rewriting by enabling mod_rewrite in your apache config.
<IfModule mod_rewrite.c>
    RewriteEngine On

    # This gives ontowiki an easy hint that rewrite is enabled
    <IfModule mod_env.c>
        SetEnv ONTOWIKI_APACHE_MOD_REWRITE_ENABLED 1
    </IfModule>

    # for deployment purposes, we want to redirect to a maintenance page iff it exists
    # works only if document root is ontowiki folder
    #RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
    #RewriteCond %{REQUEST_FILENAME} !/maintenance.html
    #RewriteRule ^.*$ /maintenance.html [R=503,L]
    #ErrorDocument 503 /maintenance.html

    # favicon files are located under /application
    RewriteRule ^favicon\.(.*)$ application/favicon.$1

    # do not rewrite requests on /robots.txt or /maintenance.html
    RewriteCond %{REQUEST_URI} !/(robots.txt|maintenance.html)$
    # do not rewrite requests on resource under public in extensions
    RewriteCond %{REQUEST_URI} !/extensions/.*/public/.*$

    # do not rewrite requests on /favicon.ico and /favicon.png
    RewriteCond %{REQUEST_URI} !/favicon\.(ico|png)$

    # do not rewrite requests on files with the whitelisted extensions under extensions (if file exists)
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_URI} !/extensions/.*/.*\.(js|css|gif|ico|png|jpg|svg)$

    # do not rewrite requests on files with the whitelisted extensions under libraries/RDFauthor (if file exists)
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_URI} !/libraries/RDFauthor/.*/.*\.(js|css|gif|ico|png|jpg|svg)$

    RewriteRule ^.*$ index.php

    # Set RewriteBase if your OntoWiki virtual host is managed with VirtualDocumentRoot.
    #RewriteBase /

    # Set RewriteBase only if your OntoWiki folder is not located in your web server's root dir.
    #RewriteBase /ontowiki
</IfModule>

# if you allow short open tags, xml templates will crash
# please refer https://github.com/AKSW/OntoWiki/wiki/php.ini-recommendations
# for recommended PHP settings
# maybe php_flag is not allowed in your environment,
# but if you allow short open tags, xml templates will crash
#php_flag short_open_tag 0


### Additional Auth with external OntoWiki auth-script
### (more infos at http://code.google.com/p/mod-auth-external/)
#AuthType Basic
#AuthName OntoWiki
#AuthBasicProvider external
#AuthExternal ontowiki
#Require valid-user
### NOTE: This is needed to be included in /etc/apache2/mods-enabled/authnz_external.load or .conf
#DefineExternalAuth ontowiki pipe /path/to/ontowiki/application/scripts/mod-auth-external/ontowiki.php