Senin, 13 April 2020

Error Drupal : The Provided Host Name Is Not Valid For This Server

Jika Halaman Drupal Anda sudah dikonfigurasi untuk mengaktifkan trusted host lalu ketika halaman dibuka Anda mendapatkan error dengan pesan : “The provided host name is not valid for this server”



Error ini bisa terjadi sebab trusted host yang Anda konfigurasi dengan url yang diakses tidak sinkron. Misal Anda menyertakan www didalam konfigurasi trusted host patterns, tetapi Anda mengaksesnya tanpa www. Contoh misal setting trusted host yang Anda tambahkan mirip berikut :

$settings['trusted_host_patterns'] = [
  '^www\.ahmadzaelani\.com$',
];

Maka dikala diakses tanpa www, situs akan memperlihatkan error “The provided host name is not valid for this server”.


Untuk menanggulangi masalah tersebut, Anda mampu melakukan setting pada file .htaccess agar halaman website senantiasa diarahkan menggunakan www.  Caranya :

Buka file .htaccess kemudian cari bab bari mirip berikut ini :


 # To redirect all users to access the site WITH the 'www.' prefix, # (http://example.com/... will be redirected to http://www.example.com/...) # uncomment the following: #RewriteCond %HTTP_HOST . #RewriteCond %HTTP_HOST !^www\. [NC] #RewriteRule ^ http%ENV:protossl://www.%HTTP_HOST%REQUEST_URI [L,R=301] 
Selanjutnya rubahlah menjadi seperti berikut :
 # To redirect all users to access the site WITH the 'www.' prefix, # (http://example.com/... will be redirected to http://www.example.com/...) # uncomment the following: RewriteCond %HTTP_HOST . RewriteCond %HTTP_HOST !^www\. [NC] RewriteRule ^ http%ENV:protossl://www.%HTTP_HOST%REQUEST_URI [L,R=301] 
Dengan cara diatas, maka domain Anda akan senantiasa diakses dengan www sehingga error yang terjadi sesudah mengaktikan trusted host tidak muncul kembali.


Sumber https://root93.blogspot.com


EmoticonEmoticon