## These rules serve as a reference.  You may add these to your .htaccess as required.

# Security options, if they work in your environment. If you get a 500 error, then they won't.
# These settings are best turned off in php.ini and will be on modern hosting environments.
#<IfModule !mod_suphp.c>
	#php_flag magic_quotes_gpc Off
#</IfModule>

# Set PHP Runtime Configuration (PHPRC)
# <IfModule mod_suphp.c>
#	suPHP_ConfigPath /home/username/public_html
# </IfModule>

<IfModule mod_rewrite.c>

# Turn the rewriting engine on, if available.
RewriteEngine on

# Enable RewriteBase if Zikula is installed in a sub-directory.
# RewriteBase /your/path/to/Zikula

# Environment Variables

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=PROTOCOL:http]

RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=PROTOCOL:https]

# Correcting HTTP authentication with suPHP.
<IfModule mod_suphp.c>
	RewriteCond %{HTTP:Authorization} ^(.*)
	RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>

# Redirect www (commented out, in favor of re-direct non-www).
# RewriteCond %{HTTP_HOST} ^w{3}\.(.*)$ [NC]
# RewriteRule ^/?(.*)$ %{ENV:PROTOCOL}://%1/$1 [R=301,L]

# Redirect non-www top-level domains.
RewriteCond %{HTTP_HOST} ^[^/.]+\.[a-zA-Z]+$ [NC]
RewriteRule ^/?(.*)$ %{ENV:PROTOCOL}://www.%{HTTP_HOST}/$1 [R=301,L]

# Redirect non-www third-level domains.
RewriteCond %{HTTP_HOST} ^[^/.]+\.[a-zA-Z]{2,4}\.[a-zA-Z]{2,3}$ [NC]
RewriteRule ^/?(.*)$ %{ENV:PROTOCOL}://www.%{HTTP_HOST}/$1 [R=301,L]
.
# Handle the favicon to prevent a full request to the engine
RewriteRule ^(.*)favicon.ico - [L]

# Ensure Ajax requests are routed correctly.
RewriteRule ^(.*)/ajax.php$ ajax.php [QSA,L]

# Rewrite any unknown directories and files.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

# Re-add index.php back into the URL.
RewriteRule ^(.+) index.php?$1 [L]

</IfModule>
