Skip to content

Instantly share code, notes, and snippets.

Last active May 24, 2020 12:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
X3 Apache config file
# Basic X3 Apache config file (minimum requirements).
<VirtualHost *:80 *:443>
# Set serverName and DocumentRoot
DocumentRoot /var/www/yourwebsite
# X3 specific rules applied relative to X3 root directory
<Directory /var/www/yourwebsite/>
# Stop Apache from loading .htaccess files [OPTIONAL]
# You can now stop Apache from reading .htaccess files, which provides performance benefit.
AllowOverride None
# RewriteEngine
RewriteEngine On
# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+)\.(html|json|xml|atom|rss)$ $1/ [L]
# Add a trailing slash to directories [OPTIONAL but recommended]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.|\?)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]
# Rewrite any calls to /render to the image parser
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{QUERY_STRING} ^(?)debug($|&)
RewriteCond %{REQUEST_URI} render/
RewriteRule ^render/. app/parsers/slir/index.php?$1 [L]
# Rewrite routes to index.php if they are non-existent files/dirs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?/$1/ [L,QSA]
# Let Diagnostics know X3 is configured from server [OPTIONAL]
<IfModule mod_env.c>
# Block public web access to the X3 /config/ folder
<Directory /var/www/yourwebsite/config/>
Require all denied
# For older Apache servers, uncomment and use the line below instead.
# Deny from all
Copy link

mjau-mjau commented Mar 31, 2017

The above is the minimum code required to run X3 on Apache server. It does not assume any other settings that are not crucial for X3 to function properly.

We recommend you have proper setup for www/ssl redirects, prevent directory content listing (Options -Indexes), expire headers (mod_expires) and Gzip compression (mod_deflate). X3 Extended Apache config file example can be found here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment