Solution:
Keep redirect rule at top and make it target only main domain:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^main\.com$ [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Make sure to clear your browser cache before testing this change.
Edit:
Removing the www
in the RewriteRule
has solved the issue.