Any logged in user (including Admin) on my Drupal 8 site is directly logged out when he visit a the home page.

Say I am on whatever page (/user/1), If I visit the home page by clicking on my website logo, the home page is displayed but I am automatically being logged out and when I click the log in link, I am automatically logged in again without asking about any credentials!

I suspect (but not sure) this might be because of those codes on my settings.php file:

$settings['trusted_host_patterns'] = array(

Note: I am using pathauto module.

any help please regarding this weird behaviour ?

Drupal: 8.6.10 PHP: 7.1


The below code is what available in my .htaccess file.

# Force redirect everything to HTTPS
   RewriteCond %{HTTPS} off
   RewriteCond %{HTTP:X-Forwarded-Proto} !https
   RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/foo will be redirected to http://example.com/foo)
# uncomment the following:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  • 3
    Have a look at the url on these pages. Is one www.my.domainname.com and the other my.domainname.com? As by logging into the www version doesn't mean you'll automaitcally be logged into the non-www version. You should add a htacess redirect to always put all traffic either on www. or without www – Leigh Mar 11 at 13:05
  • It is not the case of mine... I have both url starts without "www", please have a look to my update above – Charbel El Azzi Mar 11 at 14:08
  • 1
    Report on exact urls of your first step and where you end up. See off you are going from http to https or vice versa. See if there is any entry in the logs that reveals what might be going on. – GiorgosK Mar 11 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.