Form state redirects do not respect https on some forms I added custom redirects, for example on the user login form:

function my_module_user_login_submit(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form_state-&gt;setRedirect('view.my_custom_view.page_1');
}


This is working well even with https on my test server: the user will be redirected after login to the view page with https, let's say https://my-domain.de/my-view-page

On another server the same is not working: on this server the domain is only reachable via https - not via http. This means calling http://my-domain.de will lead to a server error only using https://my-domain.de the project will be displayed. Now when I login I will be redirected to http://my-domain.de/my-view-page (without https) which leads to this server error.

I am sucessfully logged in: when I enter https://my-domain.de/my-view-page manually I can reach this know. When logout (I did not any changes here) the same appears: After logout the user gets redirected to http://my-domain.de.

Can somebody give me a hint what can be the problem on the second server?

Best,
Tobias
On another server the same is not working: on this server the domain
  is only reachable via https - not via http


Perhaps a redirect to force HTTPS was not set up on your other server.

see Enabling HTTP Secure (HTTPS). You can do this by altering the VirtualHost definitions on your 2nd server: 


&lt;VirtualHost *:80&gt;
    ServerName www.example.com
    Redirect "/" "https://www.example.com/"
&lt;/VirtualHost&gt;



or alternatively you can do it in the .htaccess file by adding:


RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]