## Redirect from non-www to www
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
## Redirect from www to non-www
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
## Redirect from non-www to www and http to https
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Take a look at the EnforceFirstHostname and RequireSSL options for this.
UrlToolkit {
ToolkitID = my_rule
Header User-Agent BlackWidow DenyAccess
Header User-Agent Bolt DenyAccess
Header ZyBorg DenyAccess
Match ^/p/(.*).html$ Rewrite /p.php?pages=$1
Match ^/search/([0-9]+)/(.*)/mp3.html$ Rewrite /s.php?type=a&p=$1&q=$2
Match ^/search/(.*)/mp3.html$ Rewrite /s.php?type=a&q=$1
Match ^/(.*)index.php$ Rewrite /$1
}
Note that I haven't tested this. It might contain some errors. I also have no idea what THE_REQUEST in "RewriteCond %{THE_REQUEST} ^.*/index\.php" means, so I have ignored that line.