Skip to content

Instantly share code, notes, and snippets.

@mjau-mjau
Last active May 24, 2020 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjau-mjau/f4acd76bef4c1d33fba22913a9ff488e to your computer and use it in GitHub Desktop.
Save mjau-mjau/f4acd76bef4c1d33fba22913a9ff488e to your computer and use it in GitHub Desktop.
X3 Apache config file
# Basic X3 Apache config file (minimum requirements).
<VirtualHost *:80 *:443>
# Set serverName and DocumentRoot
ServerName yourwebsite.com
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>
SetEnv X3_SERVER_CONFIG On
</IfModule>
</Directory>
# 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
</Directory>
</VirtualHost>
@mjau-mjau
Copy link
Author

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:
https://gist.github.com/mjau-mjau/b8fe3d3719bc400528945b194706e6f5

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