Options -Indexes

AddType application/x-httpd-php .swt .swp

<FilesMatch "^(?!index\.php$).*\.(html|php|swt|swp)$">
	Require all denied
</FilesMatch>

<IfModule mod_negotiation.c>
	Options -MultiViews
</IfModule>

# website
<IfModule mod_rewrite.c>
	RewriteEngine On

	# Redirect www to non-www
	RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
	RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

	# Redirect HTTP to HTTPS
	RewriteCond %{HTTPS} off
	RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# url re-writes
<IfModule mod_rewrite.c>
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME}\.php -f
	# rewrite requested filename to the file that exist with php extension
	RewriteRule ^(.*)$ "$1.php" [L,NC,QSA]
</IfModule>

<IfModule mod_rewrite.c>
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME}\.php !-f
	# rewrite everything to query
	RewriteRule ^(.*)$ "index.php?q=$1" [L,NC,QSA]
</IfModule>
