Error Drupal : The provided host name is not valid for this server

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

Baca juga : 

Error ini bisa terjadi karena trusted host yang Anda konfigurasi dengan url yang diakses tidak sinkron. Misal Anda menambahkan www didalam konfigurasi trusted host patterns, namun Anda mengaksesnya tanpa www. Contoh misal setting trusted host yang Anda tambahkan seperti berikut :

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

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


Untuk mengatasi masalah tersebut, Anda bisa melakukan setting pada file .htaccess supaya halaman website selalu diarahkan menggunakan www.  Caranya :

Buka file .htaccess lalu cari bagian bari seperti 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 selalu diakses dengan www sehingga error yang terjadi setelah mengaktikan trusted host tidak muncul kembali.

0 Response to "Error Drupal : The provided host name is not valid for this server"

Post a Comment

Komentar yang Anda kirim akan terlebih dahulu di moderasi oleh Admin