Redirect www to non-www htaccess


It’s been asked a gazillion times but it’s still not working in my WordPress. I want to redirect everything to
Current code been used:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

based on this one but I also tried all in this page and of course this other one. Maybe I am missing something but this is what happens no matter what combination I tried:

#      ->
#     ->
#  ->     #wrong#
#  ->     #wrong#

I am starting to wonder whether the let’s encrypt installation has something to do… or even some other modification done in wp-config.php… I added this in the past:

if ( defined( 'WP_CLI' ) ) {
    $_SERVER['HTTP_HOST'] = 'localhost';

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');

Any idea?


>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="">

Redirect www to non-www htaccess</a>
, , , Adrian Infante 4 months 0 Answers 43 views 0

Leave an answer