htaccess: forward url including subfolder to https

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
mam885
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Mar 12, 2018 11:50 am

Mon Mar 12, 2018 12:10 pm

Hello

I'm using htaccess in order to redirect visitors from "www.domain.tld" to "domain.tld". This is working fine. Since we bought a certificate, I want to redirect users to "https://domain.tld". I found a lot of instructions and HowTo's, but none of them is working when subfolders are included (like "domain.tld/test"). Result is then always "http://domain.tld/test". Can this be disabled by my service provider? Because it doesn't make sense to me. But also, it doesn't make sense that all solutions fail to work...

Code: Select all

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Thank you very much for your time and hopefully for your help :-)

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 753
Joined: Mon Feb 22, 2016 5:52 pm

Mon Mar 12, 2018 12:26 pm

Check with your hosting provider, they should have instructions which may be specific to their set up.

Post Reply