<IfModule rewrite_module>
	RewriteEngine On

	# If instructed to do so, uncomment this line and set the value to the web path of DeskPRO.
	# For example, if DeskPRO is installed at http://www.mysite.com/help/deskpro,
	# then you would set this value to /help/deskpro
	#RewriteBase /deskpro

	# block direct access to any files/folders beginning with . (e.g. git/subversion)
	RewriteRule "(^|/)\." - [F]

	RewriteRule ^web/ - [NC,L]
	RewriteRule ^admin/.*$ index.php [NC,L]
	RewriteRule ^agent/.*$ index.php [NC,L]

	# Old chat URLs that might be called from clients using cached JS
	RewriteRule ^chat/chat\-session dp.php/chat/is-available.js [NC,L]
	RewriteRule ^index\.php/chat/chat\-session dp.php/chat/is-available.js [NC,L]

	RewriteRule ^__checkurlrewrite$ index.php?_sys=checkurl [NC,L]
	RewriteRule ^__checkurlrewrite/path$ index.php?_sys=checkurlpath [NC,L]
	RewriteRule ^sitemap\.xml$ file.php [NC,L]

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -l [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^.*$ - [NC,L]
	RewriteRule ^auto-update-status.php$ index.php?_sys=blank [NC,L]
	RewriteRule ^.*$ index.php [NC,L]
</IfModule>

# Protect hidden files and directories
<Files ~ "^config\.php|config\.new\.php|cron\.php|import\.php|upgrade\.php|schedule\.bat|web\.config$">
	Order allow,deny
	Allow from none
	Deny from all
</Files>

# Don't show directory listings for URLs which map to a directory
Options -Indexes

# Set the default handler
DirectoryIndex index.php index.html index.htm

# Override PHP settings that cannot be changed at runtime
<IfModule mod_php5.c>
	php_flag magic_quotes_gpc                 off
	php_flag magic_quotes_sybase              off
	php_flag register_globals                 off
	php_flag session.auto_start               off
	php_value mbstring.http_input             pass
	php_value mbstring.http_output            pass
	php_flag mbstring.encoding_translation    off
	php_flag zend.ze1_compatibility_mode      Off
</IfModule>