# Apache configuration for b2evolution's base folder
# Lines starting with # are comments.
# Updated 2016-01-25

# PHP / SECURITY:
<IfModule mod_php5.c>
	# On some overly "secured" systems, the following may need to be added in each folder:
	# AddHandler application/x-httpd-php5 .php

	# The following will try to configure PHP in the way b2evolution would like it to be:
	# However, these flags will only work if the server configuration allows them...

	# Increase memory limit
	php_value memory_limit 384M

	# Security settings
	php_flag register_globals Off
	php_flag allow_url_include Off
	php_flag magic_quotes_gpc Off

	# For uploading
	php_value upload_max_filesize 32M
	php_value post_max_size 40M

	# You may increase the following if PHP is not able to increase it by itself when needed
	# Otherwise it's better to keep the number low enough for general use
	php_value max_execution_time 30
	
	# You may want to turn the following to Off on production servers
	# Please do this only if you know what you're doing and will be able to retrieve potential errors from your error log
	php_flag display_errors On
	# The following is the same as 'E_ALL & ~ E_STRICT' (except those constants may not be available here)
	php_value error_reporting 30719

	# To avoid warning about the automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version
	php_value always_populate_raw_post_data -1
</IfModule>
# Duplicate all of the above for PHP7
<IfModule mod_php7.c>
	# On some overly "secured" systems, the following may need to be added in each folder:
	# AddHandler application/x-httpd-php5 .php

	# The following will try to configure PHP in the way b2evolution would like it to be:
	# However, these flags will only work if the server configuration allows them...

	# Increase memory limit
	php_value memory_limit 384M

	# Security settings
	php_flag register_globals Off
	php_flag allow_url_include Off
	php_flag magic_quotes_gpc Off

	# For uploading
	php_value upload_max_filesize 32M
	php_value post_max_size 40M

	# You may increase the following if PHP is not able to increase it by itself when needed
	# Otherwise it's better to keep the number low enough for general use
	php_value max_execution_time 30
	
	# You may want to turn the following to Off on production servers
	# Please do this only if you know what you're doing and will be able to retrieve potential errors from your error log
	php_flag display_errors On
	# The following is the same as 'E_ALL & ~ E_STRICT' (except those constants may not be available here)
	php_value error_reporting 30719

	# To avoid warning about the automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version
	php_value always_populate_raw_post_data -1
</IfModule>

# DISABLE LISTING FILES ON SERVER:
# Don't show directory contents (not desirable, especially for media folders)
Options -Indexes
# Note: if you have access to the command line of your server, it would probably
# be even better to type this:  a2dismod autoindex
# (This disables the directory listing module completely)

# DEFAULT DOCUMENT TO DISPLAY:
# In case no specific file is requested, we want to fall back to index.php
# In case some subdirectories are accessed, we want to display index.html
<IfModule mod_dir.c>
	DirectoryIndex index.php index.html
</IfModule>

# CLEAN URLS:
# The following will ensure you can pass extra params after the filename on the URL
AcceptPathInfo On

# CATCH EVERYTHING INTO B2EVO: (even if no php file appears in the URL)
# The following will allow you to have a blog running right off the site root,
# using index.php as a stub but not showing it in the URLs.
# This will add support for URLs like:  http://example.com/2006/08/29/post-title
<IfModule mod_rewrite.c>
	RewriteEngine On

	# This line may be needed or not.
	# enabling this would prevent running in a subdir like /blog/index.php
	# RewriteBase /

	# Redirect to REST API controller:
	RewriteRule ^api/v(\d+)/(.+)$ htsrv/rest.php?api_version=$1&api_request=$2 [QSA,L]

	# Redirect tracking links:
	RewriteRule ^go/(.+)$ htsrv/track.php?key=$1 [QSA,L]

	# Redirect any .htm .html or no-extension-file that's not an existing file or directory to index.php:
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	# 2020-01-10 : allow also tag names (containing dots) to be matched below, e-g: `6.11.4:`
	RewriteRule ^.+(\.(html|htm))?$ index.php [L]
</IfModule>
