howto drupal 8 URL 301 redirects


You may want to redirect all traffic from and to You can do this by adding the code below to your server configuration file, i.e., the VirtualHost definitions:

VirtualHost *:80>
    Redirect "/" ""

<VirtualHost *:443>
    # ... SSL configuration goes here

The use of RewriteRule would be appropriate if you don’t have access to the main server configuration file, and are obliged to perform this task in a .htaccess file instead:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com*
RewriteRule ^(.*)$$1 [L,R=301]

There are existing comments in .htaccess that explain how to redirect to (and vice versa), but this code here redirects both of those to


How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Scroll to Top