#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
# Apache configuration rules                 [Thomas Lange <code@nerdmind.de>] #
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
#                                                                              #
# This file contains rewrite rules for Apache. It's recommended to include the #
# rules directly into your Apache configuration for a better performance. Also #
# disable the AllowOverride directive within your Apache virtualhost (if it is #
# not already globally disabled for performance and security reasons both).    #
#                                                                              #
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#

#===============================================================================
# Enable RewriteEngine
#===============================================================================
RewriteEngine On

#===============================================================================
# ErrorDocument handler
#===============================================================================
ErrorDocument 403 /system/403.php
ErrorDocument 404 /system/404.php

#===============================================================================
# Forbidden directories
#===============================================================================
RewriteRule ^core|template/(.*)/(html|lang)/ - [F]

#===============================================================================
# Main rules
#===============================================================================
RewriteRule ^(page|post|user)/([^/]+)/$ system/$1/main.php?param=$2 [L]
RewriteRule ^(page|post|user)/$ system/$1/list.php [L]
RewriteRule ^feed/(page|post)/$ system/feed/main.php?item=$1 [L]
RewriteRule ^(feed|search)/$ system/$1/main.php [L]

#===============================================================================
# Trailing slashes
#===============================================================================
RewriteRule ^(page|post|user)/([^/]+)$ %{REQUEST_URI}/ [R,L]
RewriteRule ^(page|post|user|feed|search)$ %{REQUEST_URI}/ [R,L]
RewriteRule ^feed/(post|page)$ %{REQUEST_URI}/ [R,L]