I've been having trouble setting up my htaccess for days. I have tried many configurations that I found on the internet and even some of them here and no success.
I need in my htaccess to have the following characteristics:
- Always use HTTPS
- Always use NON-WWW
- And that does not affect my subdomains
I say this because I need to use subdomains and I can not because the current rules I have in htaccess always redirect everything to the primary domain.
I want to let you know that the settings in the DNS panel are made with "A" type entries pointing to the ip of my server.
My server is in locaweb, using Jelastic.
Below is my current htaccess rules and below my Apache configuration.
HTACCESS
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
APACHE Block 01 - Virtual Host
<VirtualHost *:80>
DocumentRoot /var/www/webroot/PASTA_SUBDOMINIO
ServerName subdominio.dominioprincipal.com.br
ServerAlias subdominios.dominioprincipal.com.br
</VirtualHost>
Block 02 - Virtual Host
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT
ServerName meusite.jelastic.com
ServerAlias dominioprincipal.com.br
</VirtualHost>
I just want to be able to access for example subdomain.main domain.com and run out of WWW, use HTTPS and fall into the correct folder inside the server ... but it's difficult. :
I could not insert the code snippets but I think you can understand.
Can you give me a light on this damn htaccess? hahahaha