Home > Software design >  Redirection "www" to "http://" of a Wordpress site by .htaccess file
Redirection "www" to "http://" of a Wordpress site by .htaccess file

Time:07-06

I'm having a problem displaying my Wordpress site with the "www." prefix.

Indeed, when I access it via http://" the homepage is displayed normally, and when I add the prefix "www." it seems that the redirection fails and displays the contents of the directory at the root of the site :

homepage www

So I wanted to modify the default .htaccess of my Wordpress website :

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

By adding this redirect rule :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.herefor.digital
RewriteRule (.*) http://herefor.digital/$1 [R=301,L]

But I don't know where to add the "www." to "http://". This crashes the site.

Yes should I according to add it, and is the procedure/syntax good on its own?

My website link : http://herefor.digital

Thanks a lot

CodePudding user response:

Regarding the crash of your site when you implement the redirect. Within the WordPress Admin navigate to Settings -> General. From there make sure the "WordPress Address (URL)" and "Site Address (URL)" is set to use https://www. and click Save Changes at the bottom.

CodePudding user response:

Ok @CBroe found the source of the problem. My "www" host was pointing to "./" instead of the "./www" directory. So I updated this via my host interface and after a few minutes, it now works!

Thanks a lot ;)

  • Related