Non-www to www htaccess redirection

I have a .net-url that works fine with www in front of it, but when the URL is just http://example.net , it brings up the page under construction.

I tried all kinds of .htaccess files, but nothing works! Help!

+2
source share
2 answers

I am not a web developer or a sys administrator, but I think the default domain should point to the same directory that the www subdomain points to.

The default is that example.com leads to your content and www.example.com forward to example.com. This is how it is done (according to http://no-www.org/ ):

RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
+3
source
 RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.example.net/$1 [R,L] 
+2
source

Source: https://habr.com/ru/post/896117/


All Articles