non-www to www htaccess redirect

2019-07-20 03:54发布

I have a .net url which works perfectly with the www in front of it but when the url is just http://example.net its bringing up an under construction page.

I have tried all sorts of .htaccess files but nothing is working! Help!

2条回答
叛逆
2楼-- · 2019-07-20 04:48
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.net/$1 [R,L]
查看更多
孤傲高冷的网名
3楼-- · 2019-07-20 04:58

Im not a web developer nor a sys admin, but i think the default domain has to point to the same directory the subdomain www points to.

Imo the default is, that example.com leads to your content and www.example.com forwards to example.com. That's how it's done (according to http://no-www.org/):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
查看更多
登录 后发表回答