NON-WWW | Force HTTPS | Sub-areas

Asked

Viewed 133 times

1

I’ve been having trouble setting up my htaccess. I’ve tried many settings I found on the internet and even some here and no success.

I need my htaccess to have the following features:

  • Always use HTTPS
  • Always use NON-WWW
  • And don’t let it affect my subdominios

I say this because I need to use subdominios and I can’t because current rules I have in htaccess redirect everything always to the main domain.

I want to record that the settings in the DNS panel are made with type "A" entries pointing to the ip of my server.

My server is in Ocaweb, using Jelastic.

Below follows 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.dominioprincipal.com.br and be without WWW, use HTTPS and fall into the correct folder inside the server... but it’s hard. :(

I couldn’t insert the code snippets nicely but I think I can understand.

Can you give me a light on this damn htaccess? hahahaha

  • Possible duplicate of Htaccess that directs to https and also to www (among several others. this is a subject full of duplicates, will find dozens of variations in the search)

  • The suggested question as already answered did not solve my problem. :/

  • And you researched other variants? Most likely in this search (currently with 295 results) you will find the solution: https://answall.com/search?q=%5Bhtaccess%5D+https

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.